Files
speckle-server/packages/webhook-service/Dockerfile
T
Iain Sproat d09bce7267 feat(docker images): Distroless (#935)
* Moves speckle-server, webhook-service, fileimport-service, monitoring-deployment, and test-deployment images to Distroless.

Partially addresses https://github.com/specklesystems/speckle-server/issues/883

* preview-service uses similar image for building and production stages
* explicitly include chromium-common dependency to prevent error in preview service
* Bump chromium packages due to package versions not being found
* Handle machine-id in distroless
    - distroless has no shell, so node-machine-id will result in an error
    - this commit introduces error handling and defaults to a uuid v4 in the case of an error
* Update binary location for readiness and liveness checks to match the binary location in Distroless
* Allow node binary path to be set as environment variable in fileimport service
2022-12-07 12:07:42 +00:00

64 lines
1.8 KiB
Docker

ARG NODE_ENV=production
FROM node:18.12.1-bullseye-slim as build-stage
ARG NODE_ENV
ENV NODE_ENV=${NODE_ENV}
WORKDIR /speckle-server
COPY .yarnrc.yml .
COPY .yarn ./.yarn
COPY package.json yarn.lock ./
COPY packages/webhook-service/package.json ./packages/webhook-service/
COPY packages/shared/package.json ./packages/shared/
RUN yarn workspaces focus --all
COPY packages/shared ./packages/shared/
COPY packages/webhook-service/src ./packages/webhook-service/
RUN yarn workspaces foreach run build
ARG WAIT_VERSION=2.8.0
ENV WAIT_VERSION=${WAIT_VERSION}
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/${WAIT_VERSION}/wait ./wait
RUN chmod +x ./wait
ARG TINI_VERSION=v0.19.0
ENV TINI_VERSION=${TINI_VERSION}
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini ./tini
RUN chmod +x ./tini
FROM node:18.12.1-bullseye-slim as dependency-stage
# yarn install
ARG NODE_ENV
ENV NODE_ENV=${NODE_ENV}
WORKDIR /speckle-server
COPY .yarnrc.yml .
COPY .yarn ./.yarn
COPY package.json yarn.lock ./
COPY packages/webhook-service/package.json ./packages/webhook-service/
COPY packages/shared/package.json ./packages/shared/
WORKDIR /speckle-server/packages/webhook-service
RUN yarn workspaces focus --production
FROM gcr.io/distroless/nodejs:18 as production-stage
ARG NODE_ENV
ENV NODE_ENV=${NODE_ENV}
WORKDIR /speckle-server/packages/webhook-service/
COPY packages/webhook-service/src .
COPY --from=build-stage /speckle-server/wait /usr/bin/wait
COPY --from=build-stage /speckle-server/tini /usr/bin/tini
COPY --from=build-stage /speckle-server/packages/shared ./packages/shared
COPY --from=build-stage /speckle-server/packages/webhook-service ./packages/webhook-service
COPY --from=dependency-stage /speckle-server/node_modules ./node_modules
ENTRYPOINT [ "tini", "--", "/nodejs/bin/node", "main.js"]