build(docker/backend): refactor backend Dockerfile

This commit is contained in:
Sarah Vaupel 2025-01-24 11:04:52 +01:00
parent c83ed1fc39
commit 2af27e2624

View File

@ -25,42 +25,11 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get -y update && apt-get -y install texlive-latex-recommended texlive-luatex texlive-plain-generic texlive-lang-german texlive-lang-english
# locally these two should be identical, so that compilation results are written out into the file dir.
# in CI-pipelines these two should be different, so that the container caches the compilation results.
ARG MOUNT_DIR=/mnt/fradrive
ARG PROJECT_DIR=/fradrive
ENV PROJECT_DIR=/fradrive
RUN mkdir -p "${PROJECT_DIR}"
# RUN if [ "${PROJECT_DIR}" != "${MOUNT_DIR}" ] ; then cp -r "${MOUNT_DIR}"/* "${PROJECT_DIR}" ; fi
ENV STACK_ROOT="/.stack"
WORKDIR ${PROJECT_DIR}
ENV HOME=${PROJECT_DIR}
ENV STACK_ROOT="/.stack"
RUN --mount=type=bind,source=.,target=.,rw stack install yesod-bin
RUN --mount=type=bind,source=.,target=.,rw stack install hpack
# pre-build dependencies
RUN --mount=type=bind,source=.,target=.,rw \
make -- --dependencies-backend STACK_ROOT=${STACK_ROOT} IN_CONTAINER=true JOB=${JOB}
# copy source files
#COPY app/ ${PROJECT_DIR}/app
#COPY src/ ${PROJECT_DIR}/src
#COPY models/ ${PROJECT_DIR}/models
#COPY messages/ ${PROJECT_DIR}/messages
#COPY templates/ ${PROJECT_DIR}/templates
#COPY test/ ${PROJECT_DIR}/test
#COPY testdata/ ${PROJECT_DIR}/testdata
# copy frontend files
#COPY assets/ ${PROJECT_DIR}/assets
#COPY static/ ${PROJECT_DIR}/static
#COPY well-known/ ${PROJECT_DIR}/well-known
ENV FRADRIVE_MAKE_TARGET=--start-backend
ENTRYPOINT make -- ${FRADRIVE_MAKE_TARGET} STACK_ROOT="${STACK_ROOT}" IN_CONTAINER=true CONTAINER_FILE="${CONTAINER_FILE}" JOB="${JOB}" SRC="${SRC}"
EXPOSE 3000/tcp
EXPOSE 3443/tcp
RUN --mount=type=bind,source=.,target=.,rw stack install hpack