FROM docker.io/node:23-alpine3.20 as compiled

WORKDIR /tmp 
USER root

# Copy the source code into the temp folder.
COPY . /tmp

# Installing the dependencies required for compiling.
RUN npm install
RUN npm install @11ty/eleventy -g

RUN npm run compile

FROM docker.io/jitesoft/lighttpd as main

ARG UID=82
ARG GID=82

RUN mkdir -p /html /logs

COPY --chown=$UID:$GID --from=compiled /tmp/build/ /html
RUN chown -R $UID:$GID /html
RUN chown -R $UID:$GID /logs
COPY --chown=$UID:$GID --from=compiled /tmp/config/lighttpd.conf /etc/lighttpd/lighttpd.conf