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
|
**/airbin
|
||||||
**/tmp
|
**/tmp
|
||||||
**/*.rdb
|
**/*.rdb
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
.dockerignore
|
||||||
|
Dockerfile
|
||||||
|
README.md
|
||||||
stylegen
|
stylegen
|
||||||
fly.toml
|
fly.toml
|
||||||
tailwind.config.*.js
|
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
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Download dependencies
|
||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
|
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
|
|
||||||
|
# Copy source code
|
||||||
COPY . .
|
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
|
FROM scratch
|
||||||
|
|
||||||
COPY --from=build /go/bin/app /app
|
COPY --from=builder /go/bin/app /app
|
||||||
|
|
||||||
ENTRYPOINT ["/app"]
|
ENTRYPOINT ["/app"]
|
||||||
|
|
Loading…
Add table
Reference in a new issue