bitplay / Dockerfile
lxxweb's picture
Update Dockerfile
eba1a1a verified
raw
history blame contribute delete
947 Bytes
# 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"]