Skip to content

Commit 5ff5d66

Browse files
committed
feat: docker build
1 parent da0e27b commit 5ff5d66

File tree

3 files changed

+84
-1
lines changed

3 files changed

+84
-1
lines changed

Dockerfile

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# ? -------------------------
2+
# ? Base: Including OS Lib Dependencies and environment variable for build
3+
# ? -------------------------
4+
5+
FROM node:20-alpine AS base
6+
7+
ENV DOCKER_BUILD=1
8+
ENV NEXT_PUBLIC_REALTIME_URL=https://rtss.crackncode.org
9+
ENV NEXT_PUBLIC_AWS_URL=https://prginth01.sgp1.cdn.digitaloceanspaces.com
10+
11+
ENV GITHUB_ID=mockvalue
12+
ENV GITHUB_SECRET=mockvalue
13+
ENV GOOGLE_CLIENT_ID=mockvalue
14+
ENV GOOGLE_CLIENT_SECRET=mockvalue
15+
16+
ENV BUCKET_NAME=mockvalue
17+
ENV BUCKET_KEY_ID=mockvalue
18+
ENV BUCKET_KEY_SECRET=mockvalue
19+
ENV BUCKET_ENDPOINT=mockvalue
20+
ENV BUCKET_REGION=mockvalue
21+
22+
# ? -------------------------
23+
# ? Builder: Build production Next.js application to .next
24+
# ? -------------------------
25+
26+
FROM base AS builder
27+
28+
RUN apk add python3 make gcc g++
29+
30+
WORKDIR /app
31+
32+
RUN corepack enable
33+
34+
COPY package.json pnpm-lock.yaml* ./
35+
RUN pnpm install --frozen-lockfile
36+
37+
COPY src ./src
38+
COPY public ./public
39+
COPY next.config.mjs postcss.config.js tailwind.config.js tsconfig.json ./
40+
41+
COPY prisma ./prisma
42+
RUN pnpm prisma generate
43+
44+
COPY .env ./
45+
46+
RUN pnpm build
47+
48+
# ? -------------------------
49+
# ? Runner: Final Image for Production
50+
# ? -------------------------
51+
52+
FROM base AS runner
53+
54+
WORKDIR /app
55+
56+
LABEL name="programming.in.th"
57+
58+
USER node
59+
ENV NODE_ENV=production
60+
61+
COPY package.json ./
62+
63+
# Automatically leverage output traces to reduce image size
64+
# https://nextjs.org/docs/advanced-features/output-file-tracing
65+
COPY --chown=node:node --from=builder /app/.next/standalone ./
66+
COPY --chown=node:node --from=builder /app/.next/static ./.next/static
67+
COPY --chown=node:node --from=builder /app/public ./public
68+
69+
ENV PORT=3000
70+
ENV HOST=0.0.0.0
71+
72+
EXPOSE 3000
73+
CMD ["node", "server.js"]

docker-compose.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# For Local Testing
2+
services:
3+
progin:
4+
image: test/progin:latest
5+
container_name: progin
6+
ports:
7+
- "3000:3000"
8+
env_file:
9+
- .env

next.config.mjs

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ export default withBundleAnalyzer({
1515
hostname: 'avatars.githubusercontent.com'
1616
}
1717
]
18-
}
18+
},
19+
output: 'standalone'
1920
})

0 commit comments

Comments
 (0)