Skip to content
This repository was archived by the owner on Mar 18, 2026. It is now read-only.

Commit 50bdc88

Browse files
authored
Merge pull request #286 from X2bee/feature/hello
feat: Add Docker configuration with Dockerfile and docker-compose for…
2 parents 45ddc78 + 76f8ed8 commit 50bdc88

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed

Dockerfile

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Build stage
2+
FROM node:20-alpine AS builder
3+
4+
WORKDIR /app
5+
6+
# Install dependencies first (for better caching)
7+
COPY package.json package-lock.json* ./
8+
RUN npm ci
9+
10+
# Copy source files
11+
COPY . .
12+
13+
# Build arguments for environment variables (needed at build time for Next.js)
14+
ARG NEXT_PUBLIC_BACKEND_HOST=http://host.docker.internal
15+
ARG NEXT_PUBLIC_BACKEND_PORT=8023
16+
ARG NEXT_PUBLIC_METRICS_HOST
17+
18+
# Set environment variables for build
19+
ENV NEXT_PUBLIC_BACKEND_HOST=$NEXT_PUBLIC_BACKEND_HOST
20+
ENV NEXT_PUBLIC_BACKEND_PORT=$NEXT_PUBLIC_BACKEND_PORT
21+
ENV NEXT_PUBLIC_METRICS_HOST=$NEXT_PUBLIC_METRICS_HOST
22+
23+
# Build the application
24+
RUN npm run build
25+
RUN npm run build:embed
26+
27+
# Production stage
28+
FROM node:20-alpine AS runner
29+
30+
WORKDIR /app
31+
32+
ENV NODE_ENV=production
33+
34+
# Create non-root user for security
35+
RUN addgroup --system --gid 1001 nodejs
36+
RUN adduser --system --uid 1001 nextjs
37+
38+
# Copy necessary files from builder
39+
COPY --from=builder /app/public ./public
40+
COPY --from=builder /app/.next/standalone ./
41+
COPY --from=builder /app/.next/static ./.next/static
42+
43+
# Set correct permissions
44+
RUN chown -R nextjs:nodejs /app
45+
USER nextjs
46+
47+
EXPOSE 3000
48+
49+
ENV PORT=3000
50+
ENV HOSTNAME="0.0.0.0"
51+
52+
CMD ["node", "server.js"]

docker-compose.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
services:
2+
frontend:
3+
build:
4+
context: .
5+
dockerfile: Dockerfile
6+
args:
7+
NEXT_PUBLIC_BACKEND_HOST: ${NEXT_PUBLIC_BACKEND_HOST:-http://host.docker.internal}
8+
NEXT_PUBLIC_BACKEND_PORT: ${NEXT_PUBLIC_BACKEND_PORT:-8023}
9+
NEXT_PUBLIC_METRICS_HOST: ${NEXT_PUBLIC_METRICS_HOST:-}
10+
container_name: plateerag_frontend
11+
ports:
12+
- "${FRONTEND_PORT:-3000}:3000"
13+
environment:
14+
- NODE_ENV=production
15+
- NEXT_PUBLIC_BACKEND_HOST=${NEXT_PUBLIC_BACKEND_HOST:-http://host.docker.internal}
16+
- NEXT_PUBLIC_BACKEND_PORT=${NEXT_PUBLIC_BACKEND_PORT:-8023}
17+
- NEXT_PUBLIC_METRICS_HOST=${NEXT_PUBLIC_METRICS_HOST:-}
18+
extra_hosts:
19+
- "host.docker.internal:host-gateway"
20+
networks:
21+
- plateer_network
22+
restart: unless-stopped
23+
healthcheck:
24+
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000"]
25+
interval: 30s
26+
timeout: 10s
27+
retries: 3
28+
start_period: 40s
29+
30+
networks:
31+
plateer_network:
32+
external: true
33+
name: plateer_network

next.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { NextConfig } from 'next';
22

33
const nextConfig: NextConfig = {
4+
output: 'standalone',
45
experimental: {
56
proxyTimeout: 600000,
67
},

0 commit comments

Comments
 (0)