-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathsandbox-manager.Dockerfile
More file actions
44 lines (34 loc) · 969 Bytes
/
sandbox-manager.Dockerfile
File metadata and controls
44 lines (34 loc) · 969 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
# Build stage
FROM golang:1.25 AS builder
WORKDIR /app
# Copy go mod and sum files
COPY ../go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy the source code
COPY ../cmd/sandbox-manager ./cmd/sandbox-manager
COPY ../pkg ./pkg
COPY ../api ./api
COPY ../client ./client
COPY ../proto ./proto
COPY ../test ./test
# Build the binary
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o sandbox-manager ./cmd/sandbox-manager
# Final stage
FROM alpine:3.20 AS runtime
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
apk --no-cache add ca-certificates && \
rm -rf /usr/local/sbin/* && \
rm -rf /usr/local/bin/* && \
rm -rf /usr/sbin/* && \
rm -rf /usr/bin/* && \
rm -rf /sbin/* && \
rm -rf /bin/*
WORKDIR /
# Copy the binary from builder stage
COPY --from=builder /app/sandbox-manager .
USER 65532:65532
# Expose port
EXPOSE 8080
# Run the binary
CMD ["/sandbox-manager"]