mirror of
https://github.com/restic/restic.git
synced 2024-12-21 23:33:03 +00:00
Multistage Docker build
This commit is contained in:
parent
1827b16ade
commit
f28c8bc1c2
3 changed files with 32 additions and 7 deletions
12
.dockerignore
Normal file
12
.dockerignore
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# Folders
|
||||||
|
.git/
|
||||||
|
.github/
|
||||||
|
changelog/
|
||||||
|
doc/
|
||||||
|
docker/
|
||||||
|
helpers/
|
||||||
|
|
||||||
|
# Files
|
||||||
|
.gitignore
|
||||||
|
.golangci.yml
|
||||||
|
*.md
|
|
@ -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
|
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"]
|
ENTRYPOINT ["/usr/bin/restic"]
|
||||||
|
|
|
@ -2,10 +2,12 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "Build binary using golang docker image"
|
export DOCKER_BUILDKIT=${DOCKER_BUILDKIT-1}
|
||||||
docker run --rm -ti \
|
|
||||||
-v "`pwd`":/go/src/github.com/restic/restic \
|
|
||||||
-w /go/src/github.com/restic/restic golang:1.16-alpine go run build.go
|
|
||||||
|
|
||||||
echo "Build docker image restic/restic:latest"
|
echo "Build docker image restic/restic:latest"
|
||||||
docker build --rm -t restic/restic:latest -f docker/Dockerfile .
|
docker build \
|
||||||
|
--rm \
|
||||||
|
--pull \
|
||||||
|
--file docker/Dockerfile \
|
||||||
|
--tag restic/restic:latest \
|
||||||
|
.
|
||||||
|
|
Loading…
Reference in a new issue