mirror of
https://github.com/apricote/Listory.git
synced 2026-01-13 13:11:02 +00:00
As our api & frontend compilation processes do not depend on the target platform, we can run them once and then just build seperate final images per target platform.
63 lines
1.1 KiB
Docker
63 lines
1.1 KiB
Docker
FROM scratch as ignore
|
|
|
|
WORKDIR /listory
|
|
COPY . /listory/
|
|
|
|
##################
|
|
## common
|
|
##################
|
|
FROM --platform=$BUILDPLATFORM node:18-alpine as common
|
|
|
|
WORKDIR /app
|
|
|
|
##################
|
|
## build-api
|
|
##################
|
|
FROM common as build-api
|
|
LABEL stage="build-api"
|
|
|
|
COPY *.json /app/
|
|
RUN npm ci
|
|
|
|
COPY src/ /app/src/
|
|
RUN NODE_ENV=production npm run build
|
|
|
|
##################
|
|
## build-frontend
|
|
##################
|
|
FROM common as build-frontend
|
|
LABEL stage="build-frontend"
|
|
|
|
ARG VERSION=unknown
|
|
|
|
WORKDIR /app/frontend
|
|
|
|
COPY frontend/package*.json /app/frontend/
|
|
RUN npm ci
|
|
|
|
COPY frontend/ /app/frontend/
|
|
RUN NODE_ENV=production npm run build
|
|
|
|
##################
|
|
## app
|
|
##################
|
|
FROM node:18-alpine as app
|
|
|
|
ARG VERSION=unknown
|
|
ARG GIT_COMMIT=unknown
|
|
|
|
LABEL org.opencontainers.image.title="listory" \
|
|
org.opencontainers.image.version=$VERSION \
|
|
org.opencontainers.image.revision=$GIT_COMMIT \
|
|
stage="common"
|
|
|
|
WORKDIR /app
|
|
|
|
COPY package.json /app/
|
|
COPY package-lock.json /app/
|
|
RUN npm ci --omit=dev
|
|
|
|
COPY --from=build-api /app/dist/ /app/dist/
|
|
COPY --from=build-frontend /app/frontend/build /app/static/
|
|
|
|
CMD ["dist/main"]
|