-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdockerfile
51 lines (35 loc) · 989 Bytes
/
dockerfile
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
# Start with Node.js for the frontend
FROM node:18 AS frontend
WORKDIR /app/frontend
COPY frontend/package*.json ./
RUN npm ci
COPY frontend/svelte.config.js ./
COPY frontend/vite.config.ts ./
COPY frontend/tsconfig.json ./
COPY frontend/src/ ./src/
COPY frontend/static/ ./static/
RUN npm run build
RUN npm prune --production
# Build the backend
FROM golang:alpine AS backend
WORKDIR /app/backend
COPY backend/go.mod backend/go.sum ./
RUN go mod download
COPY backend/ .
RUN go build -o ./main .
# Final stage
FROM alpine:latest
# Install Node.js
RUN apk add --no-cache nodejs npm
# Install dependencies for Node.js
RUN apk add --no-cache libc6-compat
# Copy frontend files
WORKDIR /app/frontend
COPY --from=frontend /app/frontend ./
# Copy backend binary
WORKDIR /app/backend
COPY --from=backend /app/backend/main ./
# Expose ports (adjust as needed)
EXPOSE 4173 4000
# Start both services
CMD ["sh", "-c", "cd /app/frontend && npm run start & cd /app/backend && ./main"]