-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
38 lines (27 loc) · 1.05 KB
/
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
FROM golang:1.22.5-alpine AS builder
# Install required system packages and update certificates
RUN apk update && \
apk upgrade && \
apk add --no-cache ca-certificates && \
update-ca-certificates
# Add Maintainer Info
LABEL maintainer="AriaData <[email protected]>"
LABEL description="SOCKS5 Proxy Server in Go."
# Set the Current Working Directory inside the container
WORKDIR /build
# Copy go mod and sum files
COPY go.mod go.sum socks5-server.go ./
# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed
RUN go mod download
# Build the Go app
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o socks5-server .
######## Start a new stage from scratch #######
FROM scratch
WORKDIR /app
# Copy the Pre-built binary file from the previous stage
COPY --from=builder /build/socks5-server .
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
# Expose port 1080 to the outside
EXPOSE 1080
# Command to run the executable
CMD ["./socks5-server"]