FROM node:22-alpine

ARG CONTAINER_WEB_VERSION
ARG ENVIRONMENT
ARG BUILD_DATE
ARG GIT_COMMIT

RUN set -eux \
    & apk add \
        --no-cache \
        nodejs \
        curl

RUN curl -L https://unpkg.com/@pnpm/self-installer | node

WORKDIR /app

COPY . .

RUN echo "PUBLIC_VERSION=${CONTAINER_WEB_VERSION}" > /app/.env && \
    echo "PUBLIC_ENVIRONMENT=${ENVIRONMENT}" >> /app/.env && \
    echo "PUBLIC_BUILD_DATE=${BUILD_DATE}" >> /app/.env && \
    echo "PUBLIC_GIT_COMMIT=${GIT_COMMIT}" >> /app/.env

EXPOSE 3000

CMD ["pnpm", "install", "&&", "pnpm", "run", "dev"]
