-
Notifications
You must be signed in to change notification settings - Fork 18
/
Dockerfile
39 lines (33 loc) · 907 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
# Build stage for web assets
FROM node:20 AS web-builder
WORKDIR /app/web
COPY web/package*.json ./
RUN npm install
COPY web ./
RUN npm run build
# Build stage for Go application
FROM golang:1.23-bookworm AS go-builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
COPY --from=web-builder /app/web/build ./web/build
# Use a shell script to determine the architecture and build accordingly
COPY <<EOF /build.sh
#!/bin/sh
if [ "$(uname -m)" = "aarch64" ]; then
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w" -o kalmia main.go
else
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o kalmia main.go
fi
EOF
RUN chmod +x /build.sh && /build.sh
# Final stage
FROM node:20-slim
WORKDIR /app
# Copy built artifacts
COPY --from=go-builder /app/kalmia .
COPY --from=web-builder /app/web/build ./web/build
COPY config.json .
EXPOSE 2727
CMD ["./kalmia"]