This repository has been archived by the owner on Jun 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
165 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: github-actions | ||
directory: / | ||
schedule: | ||
interval: weekly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
name: Docker Build & Push | ||
|
||
on: | ||
push: | ||
paths-ignore: | ||
- "**.md" | ||
- "docker-compose.yml" | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
env: | ||
restic_version: "0.15.2" | ||
|
||
jobs: | ||
restic: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: true | ||
|
||
- name: Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: | | ||
ghcr.io/thesilkky/restic | ||
thesilkky/restic | ||
tags: | | ||
type=schedule,pattern={{date 'YYYYMMDD'}} | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=sha | ||
type=sha,format=long | ||
type=semver,pattern={{version}},value=v${{ env.restic_version }} | ||
flavor: | | ||
latest=true | ||
- name: Setup QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Setup Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v2 | ||
with: | ||
version: latest | ||
|
||
- name: Login to GitHub Container Registry | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Login to Docker Hub | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Cache Docker layers | ||
if: github.event_name != 'pull_request' | ||
uses: actions/cache@v3 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: cinny-${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
cinny-${{ runner.os }}-buildx- | ||
- name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
build-args: RESTIC_VERSION=${{ env.restic_version }} | ||
platforms: linux/amd64,linux/arm64 | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache-new | ||
|
||
# https://github.com/docker/build-push-action/issues/252 | ||
# https://github.com/moby/buildkit/issues/1896 | ||
- name: Move Cache | ||
if: github.event_name != 'pull_request' | ||
run: | | ||
rm -rf /tmp/.buildx-cache | ||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#syntax=docker/dockerfile:1-labs | ||
|
||
ARG GO_VERSION=1.20.6 | ||
ARG ALPINE_VERSION=3.18 | ||
ARG RESTIC_VERSION | ||
|
||
#################################################################################################### | ||
## Builder | ||
#################################################################################################### | ||
FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS builder | ||
|
||
ARG TARGETOS | ||
ARG TARGETARCH | ||
|
||
ENV CGO_ENABLE=0 | ||
|
||
RUN apk add --no-cache \ | ||
ca-certificates \ | ||
git | ||
|
||
ADD --keep-git-dir=true https://github.com/restic/restic.git#v${RESTIC_VERSION} /restic | ||
|
||
WORKDIR /restic | ||
|
||
RUN go run helpers/build-release-binaries/main.go --platform "${TARGETOS}/${TARGETARCH}" --skip-compress && \ | ||
mv "/output/restic_${TARGETOS}_${TARGETARCH}" /output/restic | ||
|
||
#################################################################################################### | ||
## Final image | ||
#################################################################################################### | ||
FROM alpine:${ALPINE_VERSION} | ||
|
||
RUN apk add --no-cache \ | ||
ca-certificates \ | ||
tzdata \ | ||
bash | ||
|
||
COPY --from=builder --chmod=755 /output/restic /usr/local/bin | ||
COPY --chmod=755 entrypoint.sh / | ||
|
||
ENTRYPOINT ["/entrypoint.sh"] | ||
|
||
CMD ["restic", "--help"] | ||
|
||
LABEL org.opencontainers.image.source="https://github.com/restic/restic.git" | ||
LABEL org.opencontainers.image.licenses="BSD-2-Clause" | ||
LABEL org.opencontainers.image.title="Restic" | ||
LABEL org.opencontainers.image.description="Fast, secure, efficient backup program" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
if [[ -f $INIT_SCRIPT ]]; then | ||
echo "Running init script: ${INIT_SCRIPT}" | ||
source "$INIT_SCRIPT" | ||
fi | ||
|
||
echo "Running Restic: $(date)" | ||
exec "$@" |