Skip to content

Commit b984869

Browse files
ci: add docker build
1 parent 5eebf42 commit b984869

File tree

4 files changed

+89
-0
lines changed

4 files changed

+89
-0
lines changed

.dockerignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Dockerfile
2+
.dockerignore
3+
node_modules
4+
npm-debug.log
5+
README.md
6+
.next
7+
.git

.github/workflows/docker.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Docker Image CI
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
name: Build
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: docker/setup-qemu-action@v3
15+
- uses: docker/setup-buildx-action@v3
16+
17+
- uses: docker/login-action@v2
18+
with:
19+
registry: ghcr.io
20+
username: ${{ github.actor }}
21+
password: ${{ secrets.GITHUB_TOKEN }}
22+
23+
- name: Build the Docker image
24+
uses: docker/build-push-action@v5
25+
with:
26+
context: .
27+
platforms: linux/amd64
28+
push: true
29+
tags: ghcr.io/polinetworkorg/admin:latest

Dockerfile

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
FROM node:22-alpine AS base
2+
3+
FROM base AS deps
4+
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
5+
RUN apk add --no-cache libc6-compat
6+
WORKDIR /app
7+
8+
# Install dependencies based on the preferred package manager
9+
COPY package.json pnpm-lock.yaml* .npmrc* ./
10+
RUN corepack enable 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+
# Next.js collects completely anonymous telemetry data about general usage.
19+
# Learn more here: https://nextjs.org/telemetry
20+
# Uncomment the following line in case you want to disable telemetry during the build.
21+
# ENV NEXT_TELEMETRY_DISABLED=1
22+
ENV SKIP_ENV_VALIDATION=true
23+
24+
RUN corepack enable pnpm && pnpm run build
25+
26+
# Production image, copy all the files and run next
27+
FROM base AS runner
28+
WORKDIR /app
29+
30+
ENV NODE_ENV=production
31+
# Uncomment the following line in case you want to disable telemetry during runtime.
32+
# ENV NEXT_TELEMETRY_DISABLED=1
33+
34+
RUN addgroup --system --gid 1001 nodejs
35+
RUN adduser --system --uid 1001 nextjs
36+
37+
COPY --from=builder /app/public ./public
38+
39+
# Automatically leverage output traces to reduce image size
40+
# https://nextjs.org/docs/advanced-features/output-file-tracing
41+
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
42+
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
43+
44+
USER nextjs
45+
46+
EXPOSE 3001
47+
ENV PORT=3001
48+
49+
# server.js is created by next build from the standalone output
50+
# https://nextjs.org/docs/pages/api-reference/config/next-config-js/output
51+
ENV HOSTNAME="0.0.0.0"
52+
CMD ["node", "server.js"]

next.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { env } from "./src/env.js";
66

77
/** @type {import("next").NextConfig} */
88
const config = {
9+
output: "standalone",
910
async rewrites() {
1011
return [
1112
{

0 commit comments

Comments
 (0)