diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6d57110 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +* +!**/*.go +!build +!cmd +!internal +!go.* diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4027577..e82998f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,16 +3,44 @@ name: Main on: push: tags: - - 'v*.*.*' + - "v*.*.*" jobs: - build: + docker: + runs-on: ubuntu-latest + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Docker Labels + id: meta + uses: crazy-max/ghaction-docker-meta@v2 + with: + images: cupcakearmy/autorestic + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v2 + with: + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + + release: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions/setup-go@v2 with: - go-version: '^1.16.3' + go-version: "^1.16.3" - name: Build run: go run build/build.go @@ -25,4 +53,4 @@ jobs: with: files: dist/* env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..65fae81 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM golang:1.16-alpine as builder + +WORKDIR /app +COPY go.* . +RUN go mod download +COPY . . +RUN go build + +FROM alpine +RUN apk add --no-cache restic rclone +COPY --from=builder /app/autorestic /usr/bin/autorestic +CMD [ "autorestic" ]