File tree Expand file tree Collapse file tree 3 files changed +171
-0
lines changed Expand file tree Collapse file tree 3 files changed +171
-0
lines changed Original file line number Diff line number Diff line change 1+ # Dependencies
2+ node_modules
3+ npm-debug.log *
4+ yarn-debug.log *
5+ yarn-error.log *
6+
7+ # Optional npm cache directory
8+ .npm
9+
10+ # Output of 'npm pack'
11+ * .tgz
12+
13+ # dotenv environment variables file
14+ .env
15+ .env.test
16+ .env.local
17+ .env.production
18+
19+ # Git
20+ .git
21+ .gitignore
22+
23+ # Docker
24+ Dockerfile *
25+ .dockerignore
26+
27+ # Documentation
28+ README.md
29+ * .md
30+
31+ # IDE
32+ .vscode /
33+ .idea /
34+
35+ # OS generated files
36+ .DS_Store
37+ .DS_Store ?
38+ ._ *
39+ .Spotlight-V100
40+ .Trashes
41+ ehthumbs.db
42+ Thumbs.db
43+
44+ # Test files
45+ ** /* .test. *
46+ ** /* .spec. *
47+ test /
48+ tests /
49+ __tests__ /
50+
51+ # Development only files
52+ .eslintrc *
53+ .prettierrc *
54+ vitest.config. *
55+ tsconfig.json
56+
57+ # CI/CD
58+ .github /
59+
60+ # Build artifacts
61+ build /
62+ dist /
63+
64+ # Logs
65+ logs
66+ * .log
Original file line number Diff line number Diff line change 1+ name : CI for Pull Requests
2+
3+ on :
4+ pull_request :
5+ branches :
6+ - main
7+ types :
8+ - opened
9+ - synchronize
10+ - reopened
11+
12+ concurrency :
13+ group : ${{ github.workflow }}-${{ github.ref }}
14+ cancel-in-progress : true
15+
16+ jobs :
17+ # build:
18+ build-image :
19+ name : Build Image
20+ runs-on : ubuntu-latest
21+ steps :
22+ - name : Checkout code
23+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
24+
25+ - name : set up QEMU
26+ uses : docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
27+ with :
28+ platforms : linux/amd64,linux/arm64
29+
30+ - name : Login Container Registry
31+ uses : docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
32+ with :
33+ registry : ghcr.io
34+ username : ${{ github.actor }}
35+ password : ${{ secrets.GITHUB_TOKEN }}
36+
37+ - name : Set up Docker Buildx
38+ users : docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
39+
40+ - name : Build image
41+ uses : docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
42+ with :
43+ context : .
44+ platforms : linux/amd64,linux/arm64
45+ push : false
46+ cache-from : type=gha
47+ cache-to : type=gha,mode=max
48+ build-args : |
49+ VERSION=XXX
50+ COMMIT_ID=${{ github.sha }}
51+ secrets : |
52+ NPM_TOKEN=${{ secrets.NPM_TOKEN }}
Original file line number Diff line number Diff line change 1+ # syntax=docker/dockerfile:1
2+
3+ # #################
4+ # Stage 1: Base image with system dependencies
5+ # #################
6+ FROM node:22-slim AS base
7+
8+ # Set working directory
9+ WORKDIR /app
10+
11+ # # Install build dependencies for native modules if needed
12+ # RUN apt-get update && apt-get install -y \
13+ # python3 \
14+ # make \
15+ # g++ \
16+ # && rm -rf /var/lib/apt/lists/*
17+
18+ # #################
19+ # Stage 2: Dependencies installation
20+ # #################
21+ FROM base AS build
22+
23+ # Copy package files for dependency installation
24+ COPY package.json package-lock.json ./
25+
26+ # Install all dependencies
27+ RUN --mount=type=cache,target=/root/.npm \
28+ npm ci --ignore-scripts
29+
30+ # Copy source code
31+ COPY . .
32+
33+ # Build the application
34+ RUN npm run build
35+
36+ # #################
37+ # Stage 3: Production stage with distroless
38+ # #################
39+ FROM gcr.io/distroless/nodejs22-debian12:nonroot AS production
40+
41+ # Set working directory
42+ WORKDIR /app
43+
44+ # Copy only the production dependencies
45+ COPY --from=build /app/dist /app/dist
46+ COPY --from=build /app/package.json /app/package.json
47+ COPY --from=build /app/package-lock.json /app/package-lock.json
48+
49+ # Set environment variables
50+ ENV NODE_ENV=production
51+
52+ # Default command for production
53+ CMD ["/nodejs/bin/node" , "/app/dist/app.js" ]
You can’t perform that action at this time.
0 commit comments