diff --git a/.dockerignore b/.dockerignore index aaa87f6..deefb52 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,6 +3,11 @@ **/airbin **/tmp **/*.rdb +.git +.gitignore +.dockerignore +Dockerfile +README.md stylegen fly.toml -tailwind.config.*.js \ No newline at end of file +tailwind.config.*.js diff --git a/Dockerfile b/Dockerfile index b385a9d..036a0c3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,26 @@ -FROM golang:1.23.2-alpine AS build +FROM golang:1.23.2-alpine AS builder WORKDIR /app +# Download dependencies COPY go.mod go.sum ./ - RUN go mod download +# Copy source code COPY . . -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o /go/bin/app +# Install UPX +RUN apk add --no-cache upx +# Build with optimizations +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \ + -ldflags='-s -w -extldflags "-static"' \ + -tags netgo,osusergo \ + -o /go/bin/app + +# Final stage FROM scratch -COPY --from=build /go/bin/app /app +COPY --from=builder /go/bin/app /app ENTRYPOINT ["/app"]