Multistage Docker build

This commit is contained in:
cimnine
2021-09-20 14:18:48 +02:00
parent 1827b16ade
commit f28c8bc1c2
3 changed files with 32 additions and 7 deletions

View File

@@ -1,7 +1,18 @@
FROM alpine:latest
FROM golang:1.16-alpine AS builder
COPY restic /usr/bin
WORKDIR /go/src/github.com/restic/restic
# Caching dependencies
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go run build.go
FROM alpine:latest AS restic
RUN apk add --update --no-cache ca-certificates fuse openssh-client tzdata
COPY --from=builder /go/src/github.com/restic/restic/restic /usr/bin
ENTRYPOINT ["/usr/bin/restic"]