move frontend compile into runtime task

This commit is contained in:
Philipp 2024-06-19 21:49:42 +00:00
parent b4689f32cb
commit ac8778f8af
3 changed files with 22 additions and 24 deletions

View File

@ -1,23 +1,5 @@
# syntax=docker/dockerfile:1 # syntax=docker/dockerfile:1
# https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/reference.md
# Stage: compile-frontend
# Purpose: Compiles the frontend
# Notes:
# - Does NPM stuff with Typescript and such
FROM --platform=$BUILDPLATFORM docker.io/node:20-bookworm-slim AS compile-frontend
COPY ./src-ui /src/src-ui
WORKDIR /src/src-ui
RUN set -eux \
&& npm update npm -g \
&& npm ci
RUN set -eux \
&& ./node_modules/.bin/ng build --configuration production
# Stage: main-app
# Purpose: The final image
FROM --platform=$BUILDPLATFORM docker.io/node:20-bookworm-slim as main-app FROM --platform=$BUILDPLATFORM docker.io/node:20-bookworm-slim as main-app
ARG DEBIAN_FRONTEND=noninteractive ARG DEBIAN_FRONTEND=noninteractive
@ -178,10 +160,8 @@ RUN --mount=type=cache,target=/root/.cache/pip/,id=pip-cache \
&& apt-get update \ && apt-get update \
&& apt-get install --yes --quiet ${BUILD_PACKAGES} && apt-get install --yes --quiet ${BUILD_PACKAGES}
WORKDIR /usr/src/paperless/paperless-ngx/ RUN set -eux \
&& npm update npm -g
# copy frontend
COPY --from=compile-frontend --chown=1000:1000 /src/src/documents/static ./src/documents/static
# add users, setup scripts # add users, setup scripts
# Mount the compiled frontend to expected location # Mount the compiled frontend to expected location

View File

@ -69,7 +69,7 @@ services:
PAPERLESS_DEBUG: true PAPERLESS_DEBUG: true
# Overrides default command so things don't shut down after the process ends. # Overrides default command so things don't shut down after the process ends.
command: /bin/sh -c "while sleep 1000; do :; done" command: /bin/sh -c "chown -R paperless:paperless /usr/src/paperless/paperless-ngx/src/documents/static/frontend && while sleep 1000; do :; done"
gotenberg: gotenberg:
image: docker.io/gotenberg/gotenberg:7.8 image: docker.io/gotenberg/gotenberg:7.8

View File

@ -56,10 +56,28 @@
"cwd": "${workspaceFolder}/src" "cwd": "${workspaceFolder}/src"
} }
}, },
{
"label": "compile frontend",
"type": "shell",
"command": "npm ci && ./node_modules/.bin/ng build --configuration production",
"group": "none",
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared",
"showReuseMessage": false,
"clear": true,
"revealProblems": "onProblem"
},
"options": {
"cwd": "${workspaceFolder}/src-ui"
}
},
{ {
"label": "Maintenance: recreate .venv", "label": "Maintenance: recreate .venv",
"type": "shell", "type": "shell",
"command": "rm -R -v .venv/* && pipenv install --dev", "command": "rm -R -v .venv/* || pipenv install --dev",
"group": "none", "group": "none",
"presentation": { "presentation": {
"echo": true, "echo": true,