-
-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docker): create distroless final image
- Loading branch information
Showing
1 changed file
with
15 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |