# Use an official ARM64 node image
FROM node:20.15-bullseye-slim

ARG DEBIAN_FRONTEND=noninteractive

# Install the required packages
RUN echo "deb http://ftp.de.debian.org/debian stable main" > /etc/apt/sources.list

RUN apt-get clean \
  && rm -rf /var/lib/apt/lists/*

RUN apt-get update && apt-get install -y --no-install-recommends \
    ca-certificates \
    apt-utils \
    chromium \
    libcups2-dev \
    libavahi-compat-libdnssd-dev \
    gconf-service \
    libasound2 \
    libatk1.0-0 \
    libcairo2 \
    libcups2 \
    libfontconfig1 \
    libgdk-pixbuf2.0-0 \
    libgtk-3-0 \
    libnspr4 \
    libpango-1.0-0 \
    libxss1 \
    fonts-liberation \
    libnss3 \
    lsb-release \
    xdg-utils \
    libaio1 \
    ghostscript \
    curl \
    git \
    wget \
    unzip \
    fonts-unfonts-core \
    locales \
    tzdata

# Generate the en_US.UTF-8 locale
RUN locale-gen en_US.UTF-8

# Set environment variables for locale and timezone
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US:en
ENV LC_ALL=en_US.UTF-8
ENV TZ=UTC

# Set timezone to UTC (using tzdata)
RUN ln -snf /usr/share/zoneinfo/UTC /etc/localtime && echo "UTC" > /etc/timezone

# Set the working directory to /app
WORKDIR /app

# copy application & configuration files
COPY . .

# run node install command
RUN yarn install

# Make port 3000 available to the world outside this container
EXPOSE 3000

CMD [ "yarn", "run", "serve" ]