Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ dist/
.DS_Store
.env
.git
.env.*
!.env.example
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: v22.21.0
node-version: v22.23.4
cache: 'npm'
cache-dependency-path: '**/package-lock.json'

Expand Down
29 changes: 21 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
FROM node:22.23.4-bookworm-slim
FROM node:22.23.4-bookworm-slim AS base
LABEL org.opencontainers.image.source="https://github.com/jetkvm/cloud-api"
WORKDIR /usr/src/app

# Prisma needs OpenSSL at runtime
# Prisma needs OpenSSL at runtime; tini forwards SIGTERM to node as PID 1
RUN apt-get update \
&& apt-get install -y --no-install-recommends openssl ca-certificates \
&& apt-get install -y --no-install-recommends openssl ca-certificates tini \
&& rm -rf /var/lib/apt/lists/*

FROM base AS build
COPY package.json package-lock.json ./
COPY prisma ./prisma
# ts-node type-checks at startup, so the @types/* devDependencies are needed at runtime
RUN npm ci
COPY tsconfig.json ./
COPY src ./src
# Type errors fail the build here instead of crashing the container at startup
RUN npx prisma generate \
&& npm run build \
&& npm prune --omit=dev

COPY . .
RUN npx prisma generate

FROM base
ENV NODE_ENV=production
ENV PORT=3000
COPY package.json ./
COPY prisma ./prisma
COPY --from=build /usr/src/app/node_modules ./node_modules
COPY --from=build /usr/src/app/dist ./dist

USER node
EXPOSE 3000
CMD ["npm", "run", "start"]
HEALTHCHECK --interval=10s --timeout=5s --start-period=20s --retries=3 \
CMD ["node", "-e", "fetch('http://localhost:' + process.env.PORT + '/healthz').then(r => process.exit(r.ok ? 0 : 1), () => process.exit(1))"]
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["node", "dist/index.js"]
68 changes: 50 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading