Revert "chore(dockerfile): move to distroless (#2885)" (#2888)

This reverts commit a1a3428737.
This commit is contained in:
Iain Sproat 2024-09-05 15:03:47 +01:00 коммит произвёл GitHub
Родитель a1a3428737
Коммит 9d8cd0f351
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
3 изменённых файлов: 20 добавлений и 14 удалений

Просмотреть файл

@ -39,7 +39,7 @@ services:
healthcheck:
test:
- CMD
- /nodejs/bin/node
- node
- -e
- "try { require('node:http').request({headers: {'Content-Type': 'application/json'}, port:3000, hostname:'127.0.0.1', path:'/readiness', method: 'GET', timeout: 2000 }, (res) => { body = ''; res.on('data', (chunk) => {body += chunk;}); res.on('end', () => {process.exit(res.statusCode != 200 || body.toLowerCase().includes('error'));}); }).end(); } catch { process.exit(1); }"
interval: 10s

Просмотреть файл

@ -1,7 +1,7 @@
ARG NODE_ENV=production
ARG SPECKLE_SERVER_VERSION=custom
FROM node:18-bookworm-slim@sha256:408f8cbbb7b33a5bb94bdb8862795a94d2b64c2d516856824fd86c4a5594a443 AS build-stage
FROM node:18-bookworm-slim@sha256:408f8cbbb7b33a5bb94bdb8862795a94d2b64c2d516856824fd86c4a5594a443 as build-stage
ARG NODE_ENV
ARG SPECKLE_SERVER_VERSION
WORKDIR /speckle-server
@ -39,7 +39,7 @@ RUN yarn workspaces foreach -W run build
# install only production dependencies
# we need a clean environment, free of build dependencies
FROM node:18-bookworm-slim@sha256:408f8cbbb7b33a5bb94bdb8862795a94d2b64c2d516856824fd86c4a5594a443 AS dependency-stage
FROM node:18-bookworm-slim@sha256:408f8cbbb7b33a5bb94bdb8862795a94d2b64c2d516856824fd86c4a5594a443 as dependency-stage
ARG NODE_ENV
ARG SPECKLE_SERVER_VERSION
@ -56,20 +56,23 @@ COPY packages/objectloader/package.json ./packages/objectloader/
WORKDIR /speckle-server/packages/server
RUN yarn workspaces focus --production
FROM gcr.io/distroless/nodejs18-debian12:nonroot@sha256:afdea027580f7afcaf1f316b2b3806690c297cb3ce6ddc5cf6a15804dc1c790f AS production-stage
FROM node:18-bookworm-slim@sha256:408f8cbbb7b33a5bb94bdb8862795a94d2b64c2d516856824fd86c4a5594a443 as production-stage
ARG NODE_ENV
ARG SPECKLE_SERVER_VERSION
ARG FILE_SIZE_LIMIT_MB=100
ARG MAX_OBJECT_SIZE_MB=10
ENV NODE_ENV=${NODE_ENV} \
ENV FILE_SIZE_LIMIT_MB=${FILE_SIZE_LIMIT_MB} \
MAX_OBJECT_SIZE_MB=${MAX_OBJECT_SIZE_MB} \
NODE_ENV=${NODE_ENV} \
SPECKLE_SERVER_VERSION=${SPECKLE_SERVER_VERSION}
COPY --from=build-stage /speckle-server/wait /wait
COPY --from=build-stage /speckle-server/tini /tini
WORKDIR /speckle-server
COPY --from=build-stage /speckle-server/package.json ./package.json
COPY --from=build-stage /speckle-server/packages/shared ./packages/shared
COPY --from=build-stage /speckle-server/packages/objectloader ./packages/objectloader
COPY --from=build-stage /speckle-server/wait /wait
COPY --from=build-stage /speckle-server/tini /tini
COPY --from=build-stage /speckle-server/packages/shared /speckle-server/packages/shared
COPY --from=build-stage /speckle-server/packages/objectloader /speckle-server/packages/objectloader
COPY --from=dependency-stage /speckle-server/node_modules ./node_modules
WORKDIR /speckle-server/packages/server
@ -77,8 +80,9 @@ COPY --from=build-stage /speckle-server/packages/server/package.json ./package.j
COPY --from=build-stage /speckle-server/packages/server/dist ./dist
COPY --from=build-stage /speckle-server/packages/server/assets ./assets
COPY --from=build-stage /speckle-server/packages/server/bin ./bin
# Copy only if exists https://stackoverflow.com/questions/31528384/conditional-copy-add-in-dockerfile/46801962#46801962
COPY --from=dependency-stage /speckle-server/packages/server/node_module[s] ./node_modules
ENTRYPOINT ["/nodejs/bin/node"]
ENTRYPOINT ["node"]
CMD ["bin/www"]

Просмотреть файл

@ -73,9 +73,11 @@ spec:
periodSeconds: 10
failureThreshold: 60 # 10*60 = 600s; accounts for long-running db migrations
timeoutSeconds: 3
httpGet:
path: /liveness
port: {{ include "server.port" $ }}
exec:
command:
- node
- -e
- "try { require('node:http').request({headers: {'Content-Type': 'application/json'}, port:3000, hostname:'127.0.0.1', path:'/liveness', method: 'GET', timeout: 2000 }, (res) => { body = ''; res.on('data', (chunk) => {body += chunk;}); res.on('end', () => {process.exit(res.statusCode != 200 || body.toLowerCase().includes('error'));}); }).end(); } catch { process.exit(1); }"
livenessProbe:
periodSeconds: 60