Dockerfile updates

This commit is contained in:
Darren Clarke 2023-05-26 12:02:55 +00:00
parent 842dd95e43
commit 6dc4cfd3cc
21 changed files with 74 additions and 63 deletions

View file

@ -1,37 +1,49 @@
FROM node:18-bullseye-slim as builder
LABEL maintainer="Darren Clarke <darren@redaranj.com>"
FROM node:20 AS base
FROM base AS builder
ARG APP_DIR=/opt/link
RUN mkdir -p ${APP_DIR}/
COPY . ${APP_DIR}/
RUN chown -R node ${APP_DIR}/
USER node
RUN npm i -g turbo
WORKDIR ${APP_DIR}
RUN npm install
RUN npm run build
COPY . .
RUN turbo prune --scope=link --docker
FROM node:18-bullseye-slim
FROM base AS installer
ARG APP_DIR=/opt/link
WORKDIR ${APP_DIR}
COPY .gitignore .gitignore
COPY --from=builder ${APP_DIR}/out/json/ .
COPY --from=builder ${APP_DIR}/out/package-lock.json ./package-lock.json
RUN npm install
COPY --from=builder ${APP_DIR}/out/full/ .
RUN npm i -g turbo
RUN turbo run build --filter=link
FROM base AS runner
ARG APP_DIR=/opt/link
WORKDIR ${APP_DIR}/
ARG BUILD_DATE
ARG VERSION
LABEL maintainer="Darren Clarke <darren@redaranj.com>"
LABEL org.label-schema.build-date=$BUILD_DATE
LABEL org.label-schema.version=$VERSION
ARG APP_DIR=/opt/link
ENV APP_DIR ${APP_DIR}
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
apt-get install -y --no-install-recommends \
dumb-init
RUN mkdir -p ${APP_DIR}
RUN chown -R node ${APP_DIR}/
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
USER node
WORKDIR ${APP_DIR}
COPY --from=builder ${APP_DIR}/node_modules ./node_modules
COPY --from=builder ${APP_DIR}/.next ./.next
COPY --from=builder ${APP_DIR}/next.config.js ./next.config.js
COPY --from=installer ${APP_DIR}/node_modules/ ./node_modules/
COPY --from=installer ${APP_DIR}/apps/link/ ./apps/link/
USER root
RUN chmod +x ./apps/link/docker-entrypoint.sh
USER node
EXPOSE 3000
ENV PORT 3000
ENV NODE_ENV production
COPY package.json ./
ENTRYPOINT ["/docker-entrypoint.sh"]
ENTRYPOINT ["./apps/link/docker-entrypoint.sh"]