From 92170540c688e58b8154d8eff74e722eb756c754 Mon Sep 17 00:00:00 2001 From: Jamie Scott Date: Sat, 12 Oct 2024 13:28:23 +0100 Subject: [PATCH] Build frontend during docker build --- .dockerignore | 4 ++-- compose.yaml | 3 +++ docker/Dockerfile | 19 +++++++++++++++---- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.dockerignore b/.dockerignore index 1adf5fec..1d95d8cf 100644 --- a/.dockerignore +++ b/.dockerignore @@ -9,9 +9,9 @@ tmp # Docker extra docker -frontend .editorconfig .eslintrc.cjs .git .gitignore -README.md +.github +*.md diff --git a/compose.yaml b/compose.yaml index b2b7bdb0..28b54328 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,6 +1,9 @@ services: dockge: image: louislam/dockge:1 + build: + context: . + dockerfile: docker/Dockerfile restart: unless-stopped ports: # Host Port : Container Port diff --git a/docker/Dockerfile b/docker/Dockerfile index 2e167a8b..ce84208d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -4,9 +4,19 @@ FROM louislam/dockge:build-healthcheck AS build_healthcheck ############################################ -# Build +# Build frontend ############################################ -FROM louislam/dockge:base AS build +FROM louislam/dockge:base AS build_frontend +WORKDIR /app +COPY --chown=node:node . . +RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ + pnpm install && \ + pnpm run build:frontend + +############################################ +# Install node modules +############################################ +FROM louislam/dockge:base AS build_nodemodules WORKDIR /app COPY --chown=node:node ./package.json ./package.json COPY --chown=node:node ./pnpm-lock.yaml ./pnpm-lock.yaml @@ -18,8 +28,9 @@ RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-l FROM louislam/dockge:base AS release WORKDIR /app COPY --chown=node:node --from=build_healthcheck /app/extra/healthcheck /app/extra/healthcheck -COPY --from=build /app/node_modules /app/node_modules -COPY --chown=node:node . . +COPY --from=build_frontend /app/frontend-dist /app/frontend-dist +COPY --from=build_nodemodules /app/node_modules /app/node_modules +COPY --chown=node:node . . RUN mkdir ./data VOLUME /app/data