px / Dockerfile
caidaoli's picture
添加时区支持,禁用文本上传选项,并更新环境变量示例
63c2de8
raw
history blame contribute delete
681 Bytes
# Start from the official Golang image
FROM golang:1.23-alpine AS build
# Set working directory
WORKDIR /app
# Copy go.mod and go.sum files first for better caching
COPY go.mod go.sum* ./
# Download dependencies
RUN go mod download
# Copy the source code
COPY . .
# Build the application
RUN CGO_ENABLED=0 GOOS=linux go build -o main ./main.go
# Create a minimal production image
FROM alpine:latest
# Install timezone data and set timezone to Beijing
RUN apk add --no-cache tzdata
ENV TZ=Asia/Shanghai
# Create app directory and set permissions
WORKDIR /app
COPY --from=build /app/main .
# Command to run the executable
CMD ["./main"]