mirror of
https://github.com/octoleo/restic.git
synced 2024-12-23 11:28:54 +00:00
Merge pull request #3520 from nxt-engineering/Docker
Docker Multistage build
This commit is contained in:
commit
829c0a67af
12
.dockerignore
Normal file
12
.dockerignore
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# Folders
|
||||||
|
.git/
|
||||||
|
.github/
|
||||||
|
changelog/
|
||||||
|
doc/
|
||||||
|
docker/
|
||||||
|
helpers/
|
||||||
|
|
||||||
|
# Files
|
||||||
|
.gitignore
|
||||||
|
.golangci.yml
|
||||||
|
*.md
|
41
.github/workflows/tests.yml
vendored
41
.github/workflows/tests.yml
vendored
@ -269,3 +269,44 @@ jobs:
|
|||||||
echo "check if go.mod and go.sum are up to date"
|
echo "check if go.mod and go.sum are up to date"
|
||||||
go mod tidy
|
go mod tidy
|
||||||
git diff --exit-code go.mod go.sum
|
git diff --exit-code go.mod go.sum
|
||||||
|
|
||||||
|
docker:
|
||||||
|
name: docker
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v3
|
||||||
|
with:
|
||||||
|
# list of Docker images to use as base name for tags
|
||||||
|
images: |
|
||||||
|
restic/restic
|
||||||
|
# generate Docker tags based on the following events/attributes
|
||||||
|
tags: |
|
||||||
|
type=schedule
|
||||||
|
type=ref,event=branch
|
||||||
|
type=ref,event=pr
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=semver,pattern={{major}}
|
||||||
|
type=sha
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
id: docker_build
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
push: false
|
||||||
|
context: .
|
||||||
|
file: docker/Dockerfile
|
||||||
|
pull: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
@ -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 New Issue
Block a user