-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
104 lines (86 loc) · 2.3 KB
/
Dockerfile
File metadata and controls
104 lines (86 loc) · 2.3 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# syntax=docker/dockerfile:1.7
# Multi-stage Dockerfile for voidrun
# Stage 1: Build stage
FROM golang:1.24.11-alpine AS builder
# Speed up module downloads and allow caching
ENV GOPROXY=https://proxy.golang.org,direct
# Install build dependencies
RUN apk add --no-cache \
git \
gcc \
musl-dev \
ca-certificates \
tzdata
# Set working directory
WORKDIR /build
# Copy go mod files
COPY go.mod go.sum ./
# Download dependencies
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go mod download && \
go mod verify
# Copy source code
COPY cmd ./cmd
COPY config ./config
COPY handler ./handler
COPY metrics ./metrics
COPY middleware ./middleware
COPY model ./model
COPY monitoring ./monitoring
COPY repository ./repository
COPY runtime ./runtime
COPY server ./server
COPY service ./service
COPY util ./util
# Build the application with optimizations
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build \
-trimpath \
-ldflags="-s -w" \
-o voidrun \
./cmd/server/main.go
# Build setup-net CLI
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build \
-trimpath \
-ldflags="-s -w" \
-o voidrun-setup-net \
./cmd/setup-net/main.go
# Verify binary was created
RUN ls -lh /build/voidrun
# Stage 2: Runtime stage
FROM alpine:3.20
# Install runtime dependencies
# Note: cloud-hypervisor must be installed on the host at /usr/local/bin/cloud-hypervisor
RUN apk add --no-cache \
ca-certificates \
tzdata \
bash \
curl \
jq \
socat \
iproute2 \
iptables \
qemu-img
# Create non-root user (optional, for security)
# RUN addgroup -g 1000 voidrun && \
# adduser -D -u 1000 -G voidrun voidrun
# Copy binary from builder
COPY --from=builder /build/voidrun /usr/local/bin/voidrun
COPY --from=builder /build/voidrun-setup-net /usr/local/bin/voidrun-setup-net
# Copy static files (dashboard)
COPY static /app/static
# Create necessary directories
RUN mkdir -p /app/logs && \
chmod +x /usr/local/bin/voidrun
# Set working directory
WORKDIR /app
# Expose the API port
EXPOSE 8080
# Run the server
CMD ["voidrun"]