Skip to content

Commit ad16c50

Browse files
Slashgearclaude
andcommitted
feat: add Dockerfile and CI Docker build & push to GHCR
Add multi-stage Dockerfile with standalone Next.js output, and a CI job that builds and pushes the image to ghcr.io on push to master. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent f6fc979 commit ad16c50

4 files changed

Lines changed: 73 additions & 0 deletions

File tree

.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
node_modules
2+
dist
3+
.git
4+
.github
5+
e2e
6+
playwright-report
7+
test-results
8+
.DS_Store
9+
.env*.local

.github/workflows/integration.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,29 @@ jobs:
3232
cache: pnpm
3333
- run: pnpm install --frozen-lockfile --prefer-offline
3434
- run: pnpm build
35+
36+
docker:
37+
name: 🐳 Docker build & push
38+
if: github.event_name == 'push'
39+
needs: nextjs
40+
runs-on: ubuntu-latest
41+
permissions:
42+
contents: read
43+
packages: write
44+
steps:
45+
- uses: actions/checkout@main
46+
- uses: docker/setup-buildx-action@v3
47+
- uses: docker/login-action@v3
48+
with:
49+
registry: ghcr.io
50+
username: ${{ github.actor }}
51+
password: ${{ secrets.GITHUB_TOKEN }}
52+
- uses: docker/build-push-action@v6
53+
with:
54+
context: .
55+
push: true
56+
tags: |
57+
ghcr.io/lyonjs/lyonjs.github.com:latest
58+
ghcr.io/lyonjs/lyonjs.github.com:${{ github.sha }}
59+
cache-from: type=gha
60+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
FROM node:24-alpine AS deps
2+
3+
RUN corepack enable pnpm
4+
5+
WORKDIR /app
6+
COPY package.json pnpm-lock.yaml ./
7+
RUN pnpm install --frozen-lockfile
8+
9+
FROM node:24-alpine AS build
10+
11+
RUN corepack enable pnpm
12+
13+
WORKDIR /app
14+
COPY --from=deps /app/node_modules ./node_modules
15+
COPY . .
16+
RUN pnpm build
17+
18+
FROM node:24-alpine AS runner
19+
20+
WORKDIR /app
21+
22+
ENV NODE_ENV=production
23+
ENV HOSTNAME=0.0.0.0
24+
ENV PORT=3000
25+
26+
RUN addgroup --system --gid 1001 nodejs && \
27+
adduser --system --uid 1001 nextjs
28+
29+
COPY --from=build /app/public ./public
30+
COPY --from=build --chown=nextjs:nodejs /app/dist/standalone ./
31+
COPY --from=build --chown=nextjs:nodejs /app/dist/static ./dist/static
32+
33+
USER nextjs
34+
35+
EXPOSE 3000
36+
37+
CMD ["node", "server.js"]

next.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const withMDX = require('@next/mdx')();
22

33
/** @type {import('next').NextConfig} */
44
const nextConfig = {
5+
output: 'standalone',
56
experimental: {
67
mdxRs: true,
78
},

0 commit comments

Comments
 (0)