File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ Dockerfile
2+ .dockerignore
3+ node_modules
4+ npm-debug.log
5+ README.md
6+ .next
7+ .git
Original file line number Diff line number Diff line change 1+ name : build-and-push-dev-image
2+
3+ on :
4+ push :
5+ branches : [main]
6+
7+ jobs :
8+ build-and-push-dev-image :
9+ runs-on : ubuntu-latest
10+ permissions :
11+ contents : read
12+ packages : write
13+ steps :
14+ - uses : actions/checkout@v3
15+
16+ - name : Set up QEMU
17+ uses : docker/setup-qemu-action@v2
18+
19+ - name : Login to GitHub Container Registry
20+ uses : docker/login-action@v2
21+ with :
22+ registry : ghcr.io
23+ username : ${{ github.actor }}
24+ password : ${{ github.token }}
25+
26+ - name : Set up Docker Buildx
27+ id : buildx
28+ uses : docker/setup-buildx-action@v2
29+ with :
30+ install : true
31+ version : v0.9.1
32+
33+ - name : Docker meta
34+ id : meta
35+ uses : docker/metadata-action@v4
36+ with :
37+ images : |
38+ ghcr.io/sqlchat/sqlchat
39+ flavor : |
40+ latest=false
41+ tags : |
42+ type=raw,value=dev
43+
44+ - name : Build and Push
45+ id : docker_build
46+ uses : docker/build-push-action@v3
47+ with :
48+ context : ./
49+ file : ./Dockerfile
50+ platforms : linux/amd64
51+ push : true
52+ tags : ${{ steps.meta.outputs.tags }}
53+ labels : ${{ steps.meta.outputs.labels }}
Original file line number Diff line number Diff line change 1+ FROM node:18-alpine AS base
2+
3+ # Install dependencies only when needed
4+ FROM base AS deps
5+ # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
6+ RUN apk add --no-cache libc6-compat
7+ WORKDIR /app
8+
9+ COPY package.json pnpm-lock.yaml* ./
10+ RUN yarn global add pnpm && pnpm i --frozen-lockfile
11+
12+ # Rebuild the source code only when needed
13+ FROM base AS builder
14+ WORKDIR /app
15+ COPY --from=deps /app/node_modules ./node_modules
16+ COPY . .
17+
18+ RUN yarn build
19+
20+ # Production image, copy all the files and run next
21+ FROM base AS runner
22+ WORKDIR /app
23+
24+ ENV NODE_ENV production
25+
26+ RUN addgroup --system --gid 1001 nodejs
27+ RUN adduser --system --uid 1001 nextjs
28+
29+ COPY --from=builder /app/public ./public
30+
31+ # Automatically leverage output traces to reduce image size
32+ # https://nextjs.org/docs/advanced-features/output-file-tracing
33+ COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
34+ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
35+
36+ USER nextjs
37+
38+ EXPOSE 3000
39+
40+ ENV PORT 3000
41+
42+ CMD ["node" , "server.js" ]
You can’t perform that action at this time.
0 commit comments