-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
72 lines (49 loc) · 1.76 KB
/
Dockerfile
File metadata and controls
72 lines (49 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Stage 1: Build Backend (Go)
FROM golang:1.23-alpine AS backend-builder
WORKDIR /build
# Copy go mod files
COPY backend/go.mod backend/go.sum ./
RUN go mod download
# Copy backend source code
COPY backend/ ./
# Build the server binary
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o server ./cmd/server
# Stage 2: Build UI (Next.js)
FROM node:20-alpine AS ui-builder
# Enable corepack for pnpm (built into Node.js 20+)
RUN corepack enable && corepack prepare pnpm@latest --activate
WORKDIR /build
# Copy UI package files and root tsconfig.json
COPY UI/package.json UI/pnpm-lock.yaml UI/pnpm-workspace.yaml UI/tsconfig.json ./
COPY UI/packages/ ./packages/
COPY UI/apps/ ./apps/
# Install dependencies
RUN pnpm install --frozen-lockfile
# Build UI
RUN pnpm build
# Stage 3: Runtime Container
FROM node:20-alpine
# Enable corepack for pnpm (built into Node.js 20+)
RUN corepack enable && corepack prepare pnpm@latest --activate
# Install dumb-init and tzdata for timezone support
RUN apk add --no-cache dumb-init tzdata
# Set timezone to Asia/Dhaka (UTC+6)
ENV TZ=Asia/Dhaka
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
WORKDIR /app
# Copy backend binary
COPY --from=backend-builder /build/server /app/server
# Copy UI - copy entire UI directory structure (needed for Next.js SSR)
COPY --from=ui-builder /build ./ui
# Install UI production dependencies only (remove dev dependencies)
WORKDIR /app/ui
RUN CI=true pnpm install --prod --frozen-lockfile --ignore-scripts
# Copy entrypoint script
COPY docker-entrypoint.sh /app/docker-entrypoint.sh
RUN chmod +x /app/docker-entrypoint.sh
WORKDIR /app
# Expose ports
EXPOSE 8080 3000
# Use dumb-init to handle signals properly
ENTRYPOINT ["dumb-init", "--"]
CMD ["/app/docker-entrypoint.sh"]