Skip to content

Commit 21a6e5e

Browse files
committed
Add docker support
1 parent cd13344 commit 21a6e5e

File tree

5 files changed

+428
-7
lines changed

5 files changed

+428
-7
lines changed

.dockerignore

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

Dockerfile

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
FROM node:20-alpine AS base
2+
3+
# 1. Install dependencies only when needed
4+
FROM base AS deps
5+
6+
WORKDIR /app
7+
COPY package.json yarn.lock ./
8+
RUN yarn --frozen-lockfile
9+
10+
11+
# 2. Build the application
12+
FROM base AS builder
13+
14+
WORKDIR /app
15+
COPY --from=deps /app/node_modules ./node_modules
16+
COPY . .
17+
RUN yarn run build
18+
19+
20+
# 3. Production image, copy all the files and run next
21+
FROM base AS runner
22+
23+
WORKDIR /app
24+
ENV NODE_ENV=production
25+
26+
# Disable Next.js telemetry during runtime
27+
ENV NEXT_TELEMETRY_DISABLED 1
28+
29+
RUN addgroup -g 1001 -S nodejs
30+
RUN adduser -S nextjs -u 1001
31+
32+
COPY --from=builder /app/public ./public
33+
34+
# Set the correct permission for prerender cache
35+
RUN mkdir .next
36+
RUN chown nextjs:nodejs .next
37+
38+
# Automatically leverage output traces to reduce image size
39+
# https://nextjs.org/docs/advanced-features/output-file-tracing
40+
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
41+
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
42+
43+
USER nextjs
44+
45+
EXPOSE 3000
46+
47+
ENV PORT=3000
48+
49+
CMD HOSTNAME="0.0.0.0" node server.js
50+
51+
52+
53+
54+
55+

next.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/** @type {import('next').NextConfig} */
22
const nextConfig = {
3+
output: 'standalone',
34
images: {
45
domains: ["static.sinfo.org", "sinfo.ams3.cdn.digitaloceanspaces.com", "sonaesierracms-v2.cdnpservers.net"]
56
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"react": "^18.2.0",
2222
"react-dom": "^18.2.0",
2323
"react-qr-code": "^2.0.12",
24+
"sharp": "0.32.6",
2425
"tailwindcss": "3.3.3",
2526
"typescript": "5.1.6"
2627
}

0 commit comments

Comments
 (0)