Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docker): create distroless final image #362

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
16 changes: 14 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
node_modules/
.circleci
.dockerignore
.git*
.prettier*
.reference-ignore
CODE_OF_CONDUCT.md
contrib
CONTRIBUTING.md
Dockerfile*
lib/
.git
Makefile
node_modules/
nodemon.json
openapitools.json
SECURITY.md
25 changes: 13 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
FROM node:18.12.1-alpine
FROM node:22-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/ ./

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

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