File size: 947 Bytes
8669cee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
eba1a1a
 
 
 
8669cee
 
eba1a1a
 
8669cee
eba1a1a
 
 
 
 
8669cee
 
eba1a1a
8669cee
 
 
eba1a1a
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
# Build stage
FROM golang:1.24-alpine AS builder

# Set working directory for the build
WORKDIR /app

# Copy module files first to leverage Docker cache
COPY go.mod go.sum ./
RUN go mod download

# Copy all source files including client directory
COPY . .

# Build the Go app with static linking
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o main .

# Final stage
FROM alpine:3.18
RUN apk --no-cache add ca-certificates

# Add a non-root user (UID/GID 1000, Hugging Face 默认用户)
RUN addgroup -g 1000 user && adduser -D -u 1000 -G user user

# Set working directory
WORKDIR /app

# Create config directory and give permissions
RUN mkdir -p /app/config && chown -R user:user /app

# Use non-root user
USER user

# Copy the compiled binary and client directory
COPY --from=builder /app/main .
COPY --from=builder /app/client ./client/

# Expose BitPlay's default port
EXPOSE 3347

# Command to run the application
CMD ["/app/main"]