Docker optimizations and cleanup
This commit is contained in:
parent
f1be386e8b
commit
9dad47b960
2 changed files with 19 additions and 5 deletions
|
@ -3,6 +3,11 @@
|
|||
**/airbin
|
||||
**/tmp
|
||||
**/*.rdb
|
||||
.git
|
||||
.gitignore
|
||||
.dockerignore
|
||||
Dockerfile
|
||||
README.md
|
||||
stylegen
|
||||
fly.toml
|
||||
tailwind.config.*.js
|
17
Dockerfile
17
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"]
|
||||
|
|
Loading…
Add table
Reference in a new issue