Docker build updates

This commit is contained in:
Darren Clarke 2024-05-14 15:31:44 +02:00
parent 3e36aef9c5
commit 67a5b60ad5
34 changed files with 89 additions and 52 deletions

View file

@ -1,4 +1,4 @@
FROM node:18-alpine as base
FROM node:20-bookworm AS base
FROM base AS builder
ARG APP_DIR=/opt/bridge-worker
@ -11,22 +11,26 @@ RUN turbo prune --scope=bridge-worker --docker
FROM base AS installer
ARG APP_DIR=/opt/bridge-worker
WORKDIR ${APP_DIR}
COPY --from=builder ${APP_DIR}/.gitignore .gitignore
COPY --from=builder ${APP_DIR}/out/json/ .
COPY --from=builder ${APP_DIR}/out/package-lock.json ./package-lock.json
COPY --from=builder ${APP_DIR}/out/full/ .
COPY --from=builder ${APP_DIR}/out/package-lock.json ./package-lock.json
RUN npm ci
RUN npm i -g turbo
RUN turbo run build --filter=bridge-worker
FROM graphile/worker:0.16.5 as runner
FROM base as runner
ARG BUILD_DATE
ARG VERSION
ARG APP_DIR=/opt/bridge-worker
RUN mkdir -p ${APP_DIR}/
ARG BUILD_DIR=${APP_DIR}/apps/bridge-worker/build/main
RUN mkdir -p ${APP_DIR}/
WORKDIR /worker
COPY --from=installer ${BUILD_DIR}/lib ${APP_DIR}/lib
COPY --from=installer ${BUILD_DIR}/tasks ${APP_DIR}/tasks
COPY --from=installer ${APP_DIR}/apps/bridge-worker/graphile.config.prod.js ./graphile.config.js
COPY --from=installer ${APP_DIR}/node_modules ${APP_DIR}/node_modules
COPY --from=installer ${APP_DIR}/package.json ${APP_DIR}/package.json
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
apt-get install -y --no-install-recommends \
dumb-init
WORKDIR ${APP_DIR}
COPY --from=installer ${APP_DIR} ./
RUN chown -R node:node ${APP_DIR}
WORKDIR ${APP_DIR}/apps/bridge-worker/
RUN chmod +x docker-entrypoint.sh
USER node
ENV NODE_ENV production
ENTRYPOINT ["/opt/bridge-worker/apps/bridge-worker/docker-entrypoint.sh"]