-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathDockerfile
More file actions
47 lines (33 loc) · 984 Bytes
/
Dockerfile
File metadata and controls
47 lines (33 loc) · 984 Bytes
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
FROM oven/bun:1 AS frontend-builder
WORKDIR /app/web
COPY web/package.json web/bun.lock ./
RUN bun install
COPY web/ ./
RUN bun run build
FROM golang:1.25-alpine AS backend-builder
RUN apk add --no-cache gcc musl-dev
WORKDIR /app
COPY backend/go.mod backend/go.sum ./
RUN go mod download
COPY backend/ ./
RUN CGO_ENABLED=1 GOOS=linux go build -a -ldflags '-linkmode external -extldflags "-static"' -o margin-server ./cmd/server
FROM node:20-alpine
RUN apk add --no-cache ca-certificates tzdata
WORKDIR /app
COPY --from=backend-builder /app/margin-server ./margin-server
COPY --from=frontend-builder /app/web/dist ./dist
COPY --from=frontend-builder /app/web/node_modules ./node_modules
ENV PORT=8080
ENV API_PORT=8081
ENV DATABASE_URL=margin.db
ENV HOST=0.0.0.0
ENV API_URL=http://localhost:8081
EXPOSE 8080
COPY <<'EOF' /app/start.sh
#!/bin/sh
PORT=$API_PORT ./margin-server &
node ./dist/server/entry.mjs &
wait -n
EOF
RUN chmod +x /app/start.sh
CMD ["/app/start.sh"]