Skip to content

Commit

Permalink
update dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
kevwan committed Mar 13, 2022
1 parent 4c2ac7e commit 5ef1496
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
10 changes: 6 additions & 4 deletions stash/Dockerfile → stash/Dockerfile.amd64
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,22 @@ ENV CGO_ENABLED 0
ENV GOOS linux
ENV GOPROXY https://goproxy.cn,direct

WORKDIR /build/zero
RUN apk update --no-cache && apk add --no-cache tzdata

WORKDIR /build

ADD go.mod .
ADD go.sum .
RUN go mod download
COPY . .
COPY stash/etc /app/etc
RUN GOARCH=amd64 go build -ldflags="-s -w" -o /app/stash stash/stash.go
RUN apk update --no-cache && apk add upx && upx /app/stash


FROM alpine
FROM scratch

RUN apk update --no-cache && apk add --no-cache ca-certificates tzdata
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai
ENV TZ Asia/Shanghai

WORKDIR /app
Expand Down
11 changes: 7 additions & 4 deletions stash/Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
FROM arm64v8/golang:alpine AS builder
FROM golang:alpine AS builder

LABEL stage=gobuilder

ENV CGO_ENABLED 0
ENV GOOS linux
ENV GOPROXY https://goproxy.cn,direct

WORKDIR /build/zero
RUN apk update --no-cache && apk add --no-cache tzdata

WORKDIR /build

ADD go.mod .
ADD go.sum .
Expand All @@ -16,9 +18,10 @@ COPY stash/etc /app/etc
RUN GOARCH=arm64 go build -ldflags="-s -w" -o /app/stash stash/stash.go


FROM arm64v8/alpine
FROM scratch

RUN apk update --no-cache && apk add --no-cache ca-certificates tzdata
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai
ENV TZ Asia/Shanghai

WORKDIR /app
Expand Down

0 comments on commit 5ef1496

Please sign in to comment.