From 82ea44c63ffee4500893c4a6e22e2e057bcbfde6 Mon Sep 17 00:00:00 2001 From: Sarah Vaupel Date: Wed, 5 Mar 2025 17:07:52 +0100 Subject: [PATCH 1/4] build(docker/backend): use non-mounted directory as stack root; install yesod-bin and hpack in CI too --- docker/backend/Dockerfile | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/docker/backend/Dockerfile b/docker/backend/Dockerfile index 0f58f2e49..2c3e585ae 100644 --- a/docker/backend/Dockerfile +++ b/docker/backend/Dockerfile @@ -25,14 +25,12 @@ 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 +ENV STACK_ROOT="/.stack" +RUN stack install yesod-bin +RUN stack install hpack + ARG PROJECT_DIR=/fradrive ENV PROJECT_DIR=${PROJECT_DIR} # RUN mkdir -p "${PROJECT_DIR}"; chmod -R 777 "${PROJECT_DIR}" WORKDIR ${PROJECT_DIR} -ENV HOME=${PROJECT_DIR} -ENV STACK_ROOT="${PROJECT_DIR}/.stack" - -RUN if [ ! -z "${IN_CI}" ]; then \ - stack install yesod-bin; \ - stack install hpack; \ -fi \ No newline at end of file +ENV HOME=${PROJECT_DIR} \ No newline at end of file From ff3d33bbf498166fde2d70ffda12f18c3fef30f3 Mon Sep 17 00:00:00 2001 From: Sarah Vaupel Date: Wed, 5 Mar 2025 18:05:37 +0100 Subject: [PATCH 2/4] build(docker/backend): switch from Dockerfile-based yesod-bin+hpack install to Makefile-based install --- Makefile | 4 ++++ docker/backend/Dockerfile | 7 ++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index e270e46f3..997f50289 100644 --- a/Makefile +++ b/Makefile @@ -297,6 +297,10 @@ endif # uniworx.cabal: # stack exec -- hpack --force +.stack: + stack install hpack + stack install yesod-bin + # HELP(compile-frontend): compile frontend assets --compile-frontend: node_modules assets esbuild.config.mjs frontend/src/env.sass npm run build diff --git a/docker/backend/Dockerfile b/docker/backend/Dockerfile index 2c3e585ae..db3ccb209 100644 --- a/docker/backend/Dockerfile +++ b/docker/backend/Dockerfile @@ -25,12 +25,9 @@ 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 -ENV STACK_ROOT="/.stack" -RUN stack install yesod-bin -RUN stack install hpack - ARG PROJECT_DIR=/fradrive ENV PROJECT_DIR=${PROJECT_DIR} # RUN mkdir -p "${PROJECT_DIR}"; chmod -R 777 "${PROJECT_DIR}" WORKDIR ${PROJECT_DIR} -ENV HOME=${PROJECT_DIR} \ No newline at end of file +ENV HOME=${PROJECT_DIR} +ENV STACK_ROOT="${PROJECT_DIR}/.stack" \ No newline at end of file From 396b365a31362216426da5d31a0eb8a964f385cc Mon Sep 17 00:00:00 2001 From: Sarah Vaupel Date: Wed, 5 Mar 2025 18:07:37 +0100 Subject: [PATCH 3/4] build(Makefile): make backend compiles/starts dependent on .stack target --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 997f50289..1acd53e2c 100644 --- a/Makefile +++ b/Makefile @@ -262,7 +262,7 @@ endif # For Reverse Proxy Problem see: https://groups.google.com/g/yesodweb/c/2EO53kSOuy0/m/Lw6tq2VYat4J # HELP(start-backend): start development instance ---start-backend: +--start-backend: .stack export YESOD_IP_FROM_HEADER=true; \ export DEV_PORT_HTTP=`cat $(CONTAINER_FILE) | grep 'DEV_PORT_HTTP=' | sed 's/DEV_PORT_HTTP=//'`; \ export DEV_PORT_HTTPS=`cat $(CONTAINER_FILE) | grep 'DEV_PORT_HTTPS=' | sed 's/DEV_PORT_HTTPS=//'`; \ @@ -282,10 +282,10 @@ endif export AVSPASS=$${AVSPASS:-nopasswordset} ; \ stack $(STACK_CORES) exec --local-bin-path $$(pwd)/bin --copy-bins -- yesod devel -p "$${DEV_PORT_HTTP}" -q "$${DEV_PORT_HTTPS}" # HELP(compile-backend): compile backend binaries ---compile-backend: +--compile-backend: .stack stack build $(STACK_CORES) --fast --profile --library-profiling --executable-profiling --flag uniworx:-library-only $(--DEVELOPMENT) --local-bin-path $$(pwd)/bin --copy-bins # HELP(dependencies-backend): (re-)build backend dependencies ---dependencies-backend: #uniworx.cabal +--dependencies-backend: .stack #uniworx.cabal chown -R `id -un`:`id -gn` "$(PROJECT_DIR)"; \ stack build -j2 --only-dependencies # HELP(lint-backend): lint backend From 8104ce96ccc69672515d9cf89ef9677f4e5149dd Mon Sep 17 00:00:00 2001 From: Sarah Vaupel Date: Wed, 5 Mar 2025 18:09:48 +0100 Subject: [PATCH 4/4] build(Makefile): move yesod-bin and hpack installs to dependencies-backend for more robustness --- Makefile | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 1acd53e2c..b8dade070 100644 --- a/Makefile +++ b/Makefile @@ -262,7 +262,7 @@ endif # For Reverse Proxy Problem see: https://groups.google.com/g/yesodweb/c/2EO53kSOuy0/m/Lw6tq2VYat4J # HELP(start-backend): start development instance ---start-backend: .stack +--start-backend: export YESOD_IP_FROM_HEADER=true; \ export DEV_PORT_HTTP=`cat $(CONTAINER_FILE) | grep 'DEV_PORT_HTTP=' | sed 's/DEV_PORT_HTTP=//'`; \ export DEV_PORT_HTTPS=`cat $(CONTAINER_FILE) | grep 'DEV_PORT_HTTPS=' | sed 's/DEV_PORT_HTTPS=//'`; \ @@ -282,11 +282,12 @@ endif export AVSPASS=$${AVSPASS:-nopasswordset} ; \ stack $(STACK_CORES) exec --local-bin-path $$(pwd)/bin --copy-bins -- yesod devel -p "$${DEV_PORT_HTTP}" -q "$${DEV_PORT_HTTPS}" # HELP(compile-backend): compile backend binaries ---compile-backend: .stack +--compile-backend: stack build $(STACK_CORES) --fast --profile --library-profiling --executable-profiling --flag uniworx:-library-only $(--DEVELOPMENT) --local-bin-path $$(pwd)/bin --copy-bins # HELP(dependencies-backend): (re-)build backend dependencies ---dependencies-backend: .stack #uniworx.cabal +--dependencies-backend: #uniworx.cabal chown -R `id -un`:`id -gn` "$(PROJECT_DIR)"; \ + stack install hpack; stack install yesod-bin; \ stack build -j2 --only-dependencies # HELP(lint-backend): lint backend --lint-backend: @@ -297,10 +298,6 @@ endif # uniworx.cabal: # stack exec -- hpack --force -.stack: - stack install hpack - stack install yesod-bin - # HELP(compile-frontend): compile frontend assets --compile-frontend: node_modules assets esbuild.config.mjs frontend/src/env.sass npm run build