shrink docker image size in half, adding back ForceColor for logrus

This commit is contained in:
yusing 2024-09-23 05:34:50 +08:00
parent 3b597eea29
commit daca4b7735
2 changed files with 6 additions and 3 deletions

View file

@ -1,4 +1,5 @@
FROM golang:1.23.1-alpine AS builder FROM golang:1.23.1-alpine AS builder
RUN apk add --no-cache tzdata
COPY src /src COPY src /src
ENV GOCACHE=/root/.cache/go-build ENV GOCACHE=/root/.cache/go-build
WORKDIR /src WORKDIR /src
@ -7,16 +8,17 @@ RUN --mount=type=cache,target="/go/pkg/mod" \
go mod download && \ go mod download && \
CGO_ENABLED=0 GOOS=linux go build -pgo=auto -o go-proxy github.com/yusing/go-proxy CGO_ENABLED=0 GOOS=linux go build -pgo=auto -o go-proxy github.com/yusing/go-proxy
FROM alpine:3.20 FROM scratch
LABEL maintainer="yusing@6uo.me" LABEL maintainer="yusing@6uo.me"
RUN apk add --no-cache tzdata # copy timezone data
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
# copy binary # copy binary
COPY --from=builder /src/go-proxy /app/ COPY --from=builder /src/go-proxy /app/
COPY schema/ /app/schema COPY schema/ /app/schema
RUN chmod +x /app/go-proxy
ENV DOCKER_HOST=unix:///var/run/docker.sock ENV DOCKER_HOST=unix:///var/run/docker.sock
ENV GOPROXY_DEBUG=0 ENV GOPROXY_DEBUG=0

View file

@ -44,6 +44,7 @@ func main() {
DisableSorting: true, DisableSorting: true,
DisableLevelTruncation: true, DisableLevelTruncation: true,
FullTimestamp: true, FullTimestamp: true,
ForceColors: true,
TimestampFormat: "01-02 15:04:05", TimestampFormat: "01-02 15:04:05",
}) })
} }