Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 27 additions & 11 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
FROM node:24.20.0-alpine3.24@sha256:e67514e5d0f6c46656005e1b693b2ec9d52e80b641307de684d4a015ba7a4eaf AS dependencies
FROM node:24.20.0-alpine3.24@sha256:e67514e5d0f6c46656005e1b693b2ec9d52e80b641307de684d4a015ba7a4eaf AS openssl-pinned

COPY scripts/ops/install-pinned-openssl.sh /tmp/install-pinned-openssl.sh

RUN sh /tmp/install-pinned-openssl.sh && rm /tmp/install-pinned-openssl.sh

FROM openssl-pinned AS dependencies

WORKDIR /app

Expand All @@ -17,21 +23,31 @@ COPY backend ./backend

RUN npm run build --workspace=@wc-telegram/backend

FROM dependencies AS migration
FROM openssl-pinned AS migration

COPY backend ./backend
ENV NODE_ENV=production
WORKDIR /app/backend

COPY backend/migration/package.json backend/migration/package-lock.json ./

RUN npm ci --omit=dev --omit=optional --no-audit --no-fund \
&& rm -rf /root/.npm \
&& apk add --repositories-file /dev/null --no-network ca-certificates-bundle \
&& apk del --repositories-file /dev/null --no-network apk-tools \
&& rm -rf /usr/local/lib/node_modules/npm /usr/local/bin/npm /usr/local/bin/npx

COPY backend/prisma ./prisma
COPY backend/prisma.config.ts ./prisma.config.ts
COPY scripts/ops/run-migrations.sh /usr/local/bin/wctm-run-migrations

RUN chmod 0555 /usr/local/bin/wctm-run-migrations

WORKDIR /app
USER node

ENTRYPOINT ["/usr/local/bin/wctm-run-migrations"]

FROM node:24.20.0-alpine3.24@sha256:e67514e5d0f6c46656005e1b693b2ec9d52e80b641307de684d4a015ba7a4eaf AS production
FROM openssl-pinned AS production

ARG ALPINE_OPENSSL_VERSION=3.5.8-r0
ARG NPM_VERSION=11.19.1

ENV NODE_ENV=production
Expand All @@ -41,14 +57,14 @@ COPY package.json package-lock.json /app/
COPY backend/package.json /app/backend/package.json
COPY telegram-bot/package.json /app/telegram-bot/package.json

RUN apk add --no-cache \
"libcrypto3=${ALPINE_OPENSSL_VERSION}" \
"libssl3=${ALPINE_OPENSSL_VERSION}" \
&& npm install --global "npm@${NPM_VERSION}" --ignore-scripts --no-audit --no-fund \
RUN npm install --global "npm@${NPM_VERSION}" --ignore-scripts --no-audit --no-fund \
&& apk add --no-cache --virtual .native-build-deps python3 make g++ \
&& npm ci --omit=dev --omit=optional --workspace=@wc-telegram/backend \
&& apk del .native-build-deps \
&& npm cache clean --force
&& npm cache clean --force \
&& apk add --repositories-file /dev/null --no-network ca-certificates-bundle \
&& apk del --repositories-file /dev/null --no-network apk-tools \
&& rm -rf /usr/local/lib/node_modules/npm /usr/local/bin/npm /usr/local/bin/npx

COPY --from=builder --chown=node:node /app/backend/dist ./dist
COPY --from=builder --chown=node:node /app/backend/prisma ./prisma
Expand Down
Loading
Loading