Build frontend during docker build

This commit is contained in:
Jamie Scott 2024-10-12 13:28:23 +01:00
parent 109222f024
commit 92170540c6
3 changed files with 20 additions and 6 deletions

View file

@ -9,9 +9,9 @@ tmp
# Docker extra # Docker extra
docker docker
frontend
.editorconfig .editorconfig
.eslintrc.cjs .eslintrc.cjs
.git .git
.gitignore .gitignore
README.md .github
*.md

View file

@ -1,6 +1,9 @@
services: services:
dockge: dockge:
image: louislam/dockge:1 image: louislam/dockge:1
build:
context: .
dockerfile: docker/Dockerfile
restart: unless-stopped restart: unless-stopped
ports: ports:
# Host Port : Container Port # Host Port : Container Port

View file

@ -4,9 +4,19 @@
FROM louislam/dockge:build-healthcheck AS build_healthcheck 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 WORKDIR /app
COPY --chown=node:node ./package.json ./package.json COPY --chown=node:node ./package.json ./package.json
COPY --chown=node:node ./pnpm-lock.yaml ./pnpm-lock.yaml 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 FROM louislam/dockge:base AS release
WORKDIR /app WORKDIR /app
COPY --chown=node:node --from=build_healthcheck /app/extra/healthcheck /app/extra/healthcheck COPY --chown=node:node --from=build_healthcheck /app/extra/healthcheck /app/extra/healthcheck
COPY --from=build /app/node_modules /app/node_modules COPY --from=build_frontend /app/frontend-dist /app/frontend-dist
COPY --chown=node:node . . COPY --from=build_nodemodules /app/node_modules /app/node_modules
COPY --chown=node:node . .
RUN mkdir ./data RUN mkdir ./data
VOLUME /app/data VOLUME /app/data