-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
73 lines (50 loc) · 1.75 KB
/
Copy pathDockerfile
File metadata and controls
73 lines (50 loc) · 1.75 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
72
73
FROM node:25.9.0-alpine AS base
# Stage 1: Build the frontend
FROM base AS frontend-builder
WORKDIR /app/frontend
RUN npm install -g pnpm@10.33.4
COPY services/frontend/package.json services/frontend/pnpm-lock.yaml ./
COPY services/frontend/pnpm-workspace.yaml ./
RUN pnpm install --frozen-lockfile
COPY services/frontend/ ./
ENV NEXT_TELEMETRY_DISABLED=1
ENV GENERATE_SOURCEMAP=false
ENV NEXT_LINT_DISABLED=1
ENV NEXT_TYPECHECK_DISABLED=1
ENV NODE_OPTIONS="--max-old-space-size=1024"
RUN pnpm run build
# Stage 2: Build the backend
FROM golang:1.26-alpine AS backend-builder
WORKDIR /app/backend
ENV GOCACHE=/tmp/go-cache
ENV GOPATH=/go
ENV HOME=/tmp
COPY services/backend/go.mod services/backend/go.sum ./
RUN go mod download
COPY services/backend/ ./
RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o justspace-backend .
# Stage 3: Final image
FROM base AS runner
WORKDIR /app
RUN apk update && apk add --no-cache \
ca-certificates \
tini \
postgresql-client
RUN addgroup --system --gid 1001 nodejs \
&& adduser --system --uid 1001 nextjs
RUN mkdir .next \
&& chown nextjs:nodejs .next
COPY --from=frontend-builder --chown=nextjs:nodejs /app/frontend/.next/standalone ./
COPY --from=frontend-builder --chown=nextjs:nodejs /app/frontend/.next/static ./.next/static
COPY --from=frontend-builder --chown=nextjs:nodejs /app/frontend/public /app/public
COPY --from=backend-builder /app/backend/justspace-backend /app/justspace-backend
RUN chown -R nextjs:nodejs /app
RUN mkdir -p /etc/justspace \
&& chown -R nextjs:nodejs /etc/justspace
RUN mkdir -p /app/data \
&& chown -R nextjs:nodejs /app/data
ENV NODE_ENV=production
EXPOSE 8080 3000
USER nextjs
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["sh", "-c", "./justspace-backend & node /app/server.js"]