-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
54 lines (44 loc) · 1.52 KB
/
Dockerfile
File metadata and controls
54 lines (44 loc) · 1.52 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
# Build stage for Frontend
FROM oven/bun:1 AS frontend-builder
WORKDIR /app/frontend
COPY frontend/package.json frontend/bun.lock* ./
RUN bun install
COPY frontend/ .
RUN bun run build
# Build stage for Backend
FROM golang:alpine AS backend-builder
WORKDIR /app/backend
# Install build dependencies for CGO (required for go-sqlite3)
RUN apk add --no-cache gcc musl-dev
COPY backend/go.mod backend/go.sum ./
RUN go mod download
COPY backend/ .
# Build the binary named "inserv-backend" with CGO enabled
RUN CGO_ENABLED=1 go build -o /inserv-backend ./cmd/server
# Final runtime stage
FROM node:20-alpine
WORKDIR /app
# Install production dependencies for frontend server
RUN npm install concurrently express http-proxy-middleware
# Copy backend binary from builder
COPY --from=backend-builder /inserv-backend ./inserv-backend
# Copy frontend build artifacts from builder to 'public' folder (as expected by server.js)
COPY --from=frontend-builder /app/frontend/dist ./public
COPY --from=frontend-builder /app/frontend/server.js ./server.js
# Copy .env file if needed, or rely on environment variables
# COPY .env .env
# Expose ports
EXPOSE 5130
EXPOSE 8088
# Set environment variables
ENV NODE_ENV=production
ENV PORT=8088
ENV ALLOW_ORIGINS=http://localhost:5130
ENV DATABASE_PATH=/data/inserv.db
ENV JWT_SECRET=your-super-secret-key-change-me-in-production
# Create data directory
RUN mkdir -p /data
# Start both services
CMD ["npx", "concurrently", "-n", "backend,frontend", "-c", "blue,green", \
"./inserv-backend", \
"node server.js"]