Skip to content

Commit

Permalink
feat(docker): create distroless final image
Browse files Browse the repository at this point in the history
  • Loading branch information
meysam81 committed Nov 2, 2024
1 parent a08de3a commit b9caf2d
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
FROM node:18.12.1-alpine
FROM node:18-alpine as builder

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

ARG LINK=no

RUN adduser -S ory -D -u 10000 -s /bin/nologin

COPY package.json .
COPY package-lock.json .
COPY package.json package-lock.json ./

RUN npm ci --fetch-timeout=600000

COPY . /usr/src/app
COPY . .

RUN if [ "$LINK" == "true" ]; then (cd ./contrib/sdk/generated; rm -rf node_modules; npm ci; npm run build); \
RUN if [ "$LINK" == "true" ]; then \
(cd ./contrib/sdk/generated; rm -rf node_modules; npm ci; npm run build) && \
cp -r ./contrib/sdk/generated/* node_modules/@ory/kratos-client/; \
fi

RUN npm run build

USER 10000
FROM gcr.io/distroless/nodejs22-debian12:nonroot

WORKDIR /usr/src/app

COPY --from=builder /usr/src/app/package.json /usr/src/app/package-lock.json ./
COPY --from=builder /usr/src/app/node_modules ./node_modules
COPY --from=builder /usr/src/app/lib ./lib

ENTRYPOINT ["/bin/sh", "-c"]
CMD ["npm run serve"]
ENV PORT=3000
EXPOSE ${PORT}

EXPOSE 3000
CMD ["/usr/src/app/lib/index.js"]

0 comments on commit b9caf2d

Please sign in to comment.