From c5e8e176a8100e0791d6b82f1492c346052afa8c Mon Sep 17 00:00:00 2001 From: brett Date: Sun, 10 Dec 2023 12:57:47 -0700 Subject: [PATCH] initial commit - moved from https://github.com/brettinternet/homelab --- .github/workflows/publish-bash.yaml | 84 +++++++++++++++++++++++ .github/workflows/publish-cgit.yaml | 84 +++++++++++++++++++++++ .github/workflows/publish-node.yaml | 84 +++++++++++++++++++++++ .github/workflows/publish-snapraid.yaml | 86 ++++++++++++++++++++++++ .gitignore | 9 +++ README.md | 5 ++ bash/.dockerignore | 1 + bash/Dockerfile | 5 ++ bash/README.md | 3 + cgit/.dockerignore | 1 + cgit/Dockerfile | 22 ++++++ cgit/README.md | 5 ++ cgit/cgit.png | Bin 0 -> 1220 bytes cgit/cgitrc.template | 79 ++++++++++++++++++++++ cgit/favicon.ico | Bin 0 -> 15406 bytes cgit/nginx.conf | 42 ++++++++++++ cgit/start.sh | 8 +++ gitolite/Dockerfile | 12 ++++ gitolite/start.sh | 41 +++++++++++ node/Dockerfile | 5 ++ node/README.md | 3 + snapraid/.dockerignore | 1 + snapraid/Dockerfile | 14 ++++ snapraid/README.md | 34 ++++++++++ snapraid/start.sh | 69 +++++++++++++++++++ 25 files changed, 697 insertions(+) create mode 100644 .github/workflows/publish-bash.yaml create mode 100644 .github/workflows/publish-cgit.yaml create mode 100644 .github/workflows/publish-node.yaml create mode 100644 .github/workflows/publish-snapraid.yaml create mode 100644 .gitignore create mode 100644 README.md create mode 100644 bash/.dockerignore create mode 100644 bash/Dockerfile create mode 100644 bash/README.md create mode 100644 cgit/.dockerignore create mode 100644 cgit/Dockerfile create mode 100644 cgit/README.md create mode 100644 cgit/cgit.png create mode 100644 cgit/cgitrc.template create mode 100644 cgit/favicon.ico create mode 100644 cgit/nginx.conf create mode 100755 cgit/start.sh create mode 100644 gitolite/Dockerfile create mode 100755 gitolite/start.sh create mode 100644 node/Dockerfile create mode 100644 node/README.md create mode 100644 snapraid/.dockerignore create mode 100644 snapraid/Dockerfile create mode 100644 snapraid/README.md create mode 100644 snapraid/start.sh diff --git a/.github/workflows/publish-bash.yaml b/.github/workflows/publish-bash.yaml new file mode 100644 index 0000000..9ab8a7c --- /dev/null +++ b/.github/workflows/publish-bash.yaml @@ -0,0 +1,84 @@ +name: Build and publish bash image + +on: # yamllint disable-line rule:truthy + push: + branches: + - main + paths: + - bash/* + - .github/workflows/publish-bash.yaml + +env: + DOCKER_USERNAME: brettinternet + IMAGE_NAME: bash + DESCRIPTION: An Alpine image for scripting with bash, curl and git using a dumb-init entrypoint + +defaults: + run: + working-directory: ./bash + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, 'skipci')" + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + with: + platforms: arm64,amd64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + username: ${{ env.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_HUB_PAT }} + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract image metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: | + ${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }} + ghcr.io/${{ github.actor }}/${{ env.IMAGE_NAME }} + flavor: latest=auto + tags: type=raw,value=latest,enable={{is_default_branch}} + + - name: Build and push Docker image + uses: docker/build-push-action@v3 + with: + context: ./${{ env.IMAGE_NAME }} + file: ./${{ env.IMAGE_NAME }}/Dockerfile + platforms: arm64,amd64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: | + org.opencontainers.image.name=${{ env.IMAGE_NAME }} + org.opencontainers.image.source=https://github.com/brettinternet/containers/tree/main/${{ env.IMAGE_NAME }} + org.opencontainers.image.description=${{ env.DESCRIPTION }} + org.opencontainers.image.licenses=MIT + + - name: Update Docker Hub Description + uses: peter-evans/dockerhub-description@v3 + with: + username: ${{ env.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_HUB_PAT }} + repository: ${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }} + short-description: ${{ env.DESCRIPTION }} + readme-filepath: ./${{ env.IMAGE_NAME }}/README.md diff --git a/.github/workflows/publish-cgit.yaml b/.github/workflows/publish-cgit.yaml new file mode 100644 index 0000000..e59282e --- /dev/null +++ b/.github/workflows/publish-cgit.yaml @@ -0,0 +1,84 @@ +name: Build and publish cgit image + +on: # yamllint disable-line rule:truthy + push: + branches: + - main + paths: + - cgit/* + - .github/workflows/publish-cgit.yaml + +env: + DOCKER_USERNAME: brettinternet + IMAGE_NAME: cgit + DESCRIPTION: A git web frontend + +defaults: + run: + working-directory: ./cgit + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, 'skipci')" + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + with: + platforms: arm64,amd64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + username: ${{ env.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_HUB_PAT }} + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract image metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: | + ${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }} + ghcr.io/${{ github.actor }}/${{ env.IMAGE_NAME }} + flavor: latest=auto + tags: type=raw,value=latest,enable={{is_default_branch}} + + - name: Build and push Docker image + uses: docker/build-push-action@v3 + with: + context: ./${{ env.IMAGE_NAME }} + file: ./${{ env.IMAGE_NAME }}/Dockerfile + platforms: arm64,amd64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: | + org.opencontainers.image.name=${{ env.IMAGE_NAME }} + org.opencontainers.image.source=https://github.com/brettinternet/containers/tree/main/${{ env.IMAGE_NAME }} + org.opencontainers.image.description=${{ env.DESCRIPTION }} + org.opencontainers.image.licenses=MIT + + - name: Update Docker Hub Description + uses: peter-evans/dockerhub-description@v3 + with: + username: ${{ env.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_HUB_PAT }} + repository: ${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }} + short-description: ${{ env.DESCRIPTION }} + readme-filepath: ./${{ env.IMAGE_NAME }}/README.md diff --git a/.github/workflows/publish-node.yaml b/.github/workflows/publish-node.yaml new file mode 100644 index 0000000..396b759 --- /dev/null +++ b/.github/workflows/publish-node.yaml @@ -0,0 +1,84 @@ +name: Build and publish node image + +on: # yamllint disable-line rule:truthy + push: + branches: + - main + paths: + - node/* + - .github/workflows/publish-node.yaml + +env: + DOCKER_USERNAME: brettinternet + IMAGE_NAME: node + DESCRIPTION: An Alpine image for scripting with node and git using a dumb-init entrypoint + +defaults: + run: + working-directory: ./node + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, 'skipci')" + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + with: + platforms: arm64,amd64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + username: ${{ env.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_HUB_PAT }} + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract image metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: | + ${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }} + ghcr.io/${{ github.actor }}/${{ env.IMAGE_NAME }} + flavor: latest=auto + tags: type=raw,value=latest,enable={{is_default_branch}} + + - name: Build and push Docker image + uses: docker/build-push-action@v3 + with: + context: ./${{ env.IMAGE_NAME }} + file: ./${{ env.IMAGE_NAME }}/Dockerfile + platforms: arm64,amd64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: | + org.opencontainers.image.name=${{ env.IMAGE_NAME }} + org.opencontainers.image.source=https://github.com/brettinternet/containers/tree/main/${{ env.IMAGE_NAME }} + org.opencontainers.image.description=${{ env.DESCRIPTION }} + org.opencontainers.image.licenses=MIT + + - name: Update Docker Hub Description + uses: peter-evans/dockerhub-description@v3 + with: + username: ${{ env.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_HUB_PAT }} + repository: ${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }} + short-description: ${{ env.DESCRIPTION }} + readme-filepath: ./${{ env.IMAGE_NAME }}/README.md diff --git a/.github/workflows/publish-snapraid.yaml b/.github/workflows/publish-snapraid.yaml new file mode 100644 index 0000000..e206ede --- /dev/null +++ b/.github/workflows/publish-snapraid.yaml @@ -0,0 +1,86 @@ +# https://docs.github.com/en/actions/publishing-packages/publishing-docker-images#publishing-images-to-github-packages +# TODO: specify package README https://github.com/docker/build-push-action/issues/722 +name: Build and publish snapraid image + +on: # yamllint disable-line rule:truthy + push: + branches: + - main + paths: + - snapraid/* + - .github/workflows/publish-snapraid.yaml + +env: + DOCKER_USERNAME: brettinternet + IMAGE_NAME: snapraid + DESCRIPTION: Snapraid backup program for disk arrays and python script runner for automation + +defaults: + run: + working-directory: ./snapraid + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, 'skipci')" + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + with: + platforms: arm64,amd64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + username: ${{ env.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_HUB_PAT }} + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract image metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: | + ${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }} + ghcr.io/${{ github.actor }}/${{ env.IMAGE_NAME }} + flavor: latest=auto + tags: type=raw,value=latest,enable={{is_default_branch}} + + - name: Build and push Docker image + uses: docker/build-push-action@v3 + with: + context: ./${{ env.IMAGE_NAME }} + file: ./${{ env.IMAGE_NAME }}/Dockerfile + platforms: arm64,amd64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: | + org.opencontainers.image.name=${{ env.IMAGE_NAME }} + org.opencontainers.image.source=https://github.com/brettinternet/containers/tree/main/${{ env.IMAGE_NAME }} + org.opencontainers.image.description=${{ env.DESCRIPTION }} + org.opencontainers.image.licenses=MIT + + - name: Update Docker Hub Description + uses: peter-evans/dockerhub-description@v3 + with: + username: ${{ env.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_HUB_PAT }} + repository: ${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }} + short-description: ${{ env.DESCRIPTION }} + readme-filepath: ./${{ env.IMAGE_NAME }}/README.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eeffb0d --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +# Trash +.DS_Store +Thumbs.db +tmp + +# scripts +node_modules +*.log +*.pem diff --git a/README.md b/README.md new file mode 100644 index 0000000..bdbd84a --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# Containers + +Hosted images for my homelab. + +See usage in [homelab](https://github.com/brettinternet/homelab) and [provision](https://github.com/brettinternet/provision). diff --git a/bash/.dockerignore b/bash/.dockerignore new file mode 100644 index 0000000..b43bf86 --- /dev/null +++ b/bash/.dockerignore @@ -0,0 +1 @@ +README.md diff --git a/bash/Dockerfile b/bash/Dockerfile new file mode 100644 index 0000000..9b9dd94 --- /dev/null +++ b/bash/Dockerfile @@ -0,0 +1,5 @@ +FROM bash:alpine3.16 + +RUN apk --update add git curl jq dumb-init + +ENTRYPOINT ["/usr/bin/dumb-init", "--"] diff --git a/bash/README.md b/bash/README.md new file mode 100644 index 0000000..28e7bd2 --- /dev/null +++ b/bash/README.md @@ -0,0 +1,3 @@ +# Bash + +An Alpine image for scripting with bash, curl, jq and git using a dumb-init entrypoint. diff --git a/cgit/.dockerignore b/cgit/.dockerignore new file mode 100644 index 0000000..b43bf86 --- /dev/null +++ b/cgit/.dockerignore @@ -0,0 +1 @@ +README.md diff --git a/cgit/Dockerfile b/cgit/Dockerfile new file mode 100644 index 0000000..ea07a20 --- /dev/null +++ b/cgit/Dockerfile @@ -0,0 +1,22 @@ +# https://wiki.alpinelinux.org/wiki/Cgit +# Alternate option: https://git.causal.agency/cgit-pink/tree/cgit.css +FROM alpine:latest + +RUN set -xe && \ + apk add --no-cache --purge -uU \ + curl git cgit py3-pygments python3 py3-markdown markdown \ + fcgiwrap spawn-fcgi nginx gettext dumb-init && \ + rm -rf /var/cache/apk/* /tmp/* && \ + mkdir -p /srv/git + +ENV ROOT_TITLE="Git" ROOT_DESC="My git repositories" SECTION_FROM_STARTPATH=0 MAX_REPO_COUNT=50 NOPLAINEMAIL=1 +COPY --chown=nginx cgit.png /usr/share/webapps/cgit/ +COPY --chown=nginx favicon.ico /usr/share/webapps/cgit/ +COPY cgitrc.template /etc/ +COPY nginx.conf /etc/nginx/ +COPY start.sh /start.sh + +VOLUME /var/lib/git /var/cache/cgit +EXPOSE 80 +ENTRYPOINT ["/usr/bin/dumb-init", "--"] +CMD ["/start.sh"] diff --git a/cgit/README.md b/cgit/README.md new file mode 100644 index 0000000..33edc62 --- /dev/null +++ b/cgit/README.md @@ -0,0 +1,5 @@ +# cgit + +[cgit](https://git.zx2c4.com/cgit/) is a git web frontend. + +Use [cgit options](https://git.zx2c4.com/cgit/tree/cgitrc.5.txt) to configure the server. diff --git a/cgit/cgit.png b/cgit/cgit.png new file mode 100644 index 0000000000000000000000000000000000000000..12034dda7e9894149da8f428becd6d4fefe3d95d GIT binary patch literal 1220 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 literal 0 HcmV?d00001 diff --git a/cgit/nginx.conf b/cgit/nginx.conf new file mode 100644 index 0000000..f493571 --- /dev/null +++ b/cgit/nginx.conf @@ -0,0 +1,42 @@ +# https://wiki.archlinux.org/title/Cgit#Nginx +worker_processes 1; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + sendfile on; + keepalive_timeout 65; + gzip on; + + # Cgit + server { + listen 80; + server_name localhost; + root /usr/share/webapps/cgit; + try_files $uri @cgit; + + # Configure HTTP transport + location ~ /.+/(info/refs|git-upload-pack) { + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME /usr/libexec/git-core/git-http-backend; + fastcgi_param PATH_INFO $uri; + fastcgi_param GIT_HTTP_EXPORT_ALL 1; + fastcgi_param GIT_PROJECT_ROOT /srv/git; + fastcgi_param HOME /srv/git; + fastcgi_pass unix:/run/fcgiwrap.sock; + } + + location @cgit { + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root/cgit.cgi; + fastcgi_param PATH_INFO $uri; + fastcgi_param QUERY_STRING $args; + fastcgi_param HTTP_HOST $server_name; + fastcgi_pass unix:/run/fcgiwrap.sock; + } + } +} diff --git a/cgit/start.sh b/cgit/start.sh new file mode 100755 index 0000000..efe0dc7 --- /dev/null +++ b/cgit/start.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +CGIT_VARS='$ROOT_TITLE:$ROOT_DESC:$SECTION_FROM_STARTPATH:$MAX_REPO_COUNT:$ROOT_README:$NOPLAINEMAIL' +envsubst "$CGIT_VARS" < /etc/cgitrc.template > /etc/cgitrc + +spawn-fcgi -U nginx -G nginx -M 600 -s /var/run/fcgiwrap.sock /usr/bin/fcgiwrap + +nginx -g "daemon off;" diff --git a/gitolite/Dockerfile b/gitolite/Dockerfile new file mode 100644 index 0000000..18a764e --- /dev/null +++ b/gitolite/Dockerfile @@ -0,0 +1,12 @@ +FROM alpine:latest + +RUN set -xe && \ + apk add --no-cache --purge -uU \ + git gitolite openssh dumb-init && \ + rm -rf /var/cache/apk/* /tmp/* + +VOLUME /var/lib/git /etc/ssh/keys +EXPOSE 22 +ENTRYPOINT ["/usr/bin/dumb-init", "--"] +COPY start.sh /start.sh +CMD ["/start.sh"] diff --git a/gitolite/start.sh b/gitolite/start.sh new file mode 100755 index 0000000..f34817a --- /dev/null +++ b/gitolite/start.sh @@ -0,0 +1,41 @@ +# https://gitolite.com/gitolite/basic-admin#appendix-1-bringing-existing-repos-into-gitolite +# https://stackoverflow.com/questions/5767850/git-on-custom-ssh-port + +#!/bin/sh + +set -- /usr/sbin/sshd -D + +# Setup SSH HostKeys if needed +for algorithm in rsa dsa ecdsa ed25519 +do + keyfile=/etc/ssh/keys/ssh_host_${algorithm}_key + [ -f $keyfile ] || ssh-keygen -q -N '' -f $keyfile -t $algorithm + grep -q "HostKey $keyfile" /etc/ssh/sshd_config || echo "HostKey $keyfile" >> /etc/ssh/sshd_config +done +# Disable unwanted authentications +perl -i -pe 's/^#?((?!Kerberos|GSSAPI)\w*Authentication)\s.*/\1 no/; s/^(PubkeyAuthentication) no/\1 yes/' /etc/ssh/sshd_config +# Disable sftp subsystem +perl -i -pe 's/^(Subsystem\ssftp\s)/#\1/' /etc/ssh/sshd_config + +# Fix permissions at every startup +chown -R git:git ~git + +# Setup gitolite admin +if [ ! -f ~git/.ssh/authorized_keys ]; then + if [ -n "$SSH_KEY" ]; then + [ -n "$SSH_KEY_NAME" ] || SSH_KEY_NAME=admin + echo "$SSH_KEY" > "/tmp/$SSH_KEY_NAME.pub" + su - git -c "gitolite setup -pk \"/tmp/$SSH_KEY_NAME.pub\"" + rm "/tmp/$SSH_KEY_NAME.pub" + else + echo "You need to specify SSH_KEY on first run to setup gitolite" + echo "You can also use SSH_KEY_NAME to specify the key name (optional)" + echo 'Example: docker run -e SSH_KEY="$(cat ~/.ssh/id_rsa.pub)" -e SSH_KEY_NAME="$(whoami)" jgiannuzzi/gitolite' + exit 1 + fi +# Check setup at every startup +else + su - git -c "gitolite setup" +fi + +exec "$@" diff --git a/node/Dockerfile b/node/Dockerfile new file mode 100644 index 0000000..00666bc --- /dev/null +++ b/node/Dockerfile @@ -0,0 +1,5 @@ +FROM node:20-alpine + +RUN apk --update add git dumb-init + +ENTRYPOINT ["/usr/bin/dumb-init", "--"] diff --git a/node/README.md b/node/README.md new file mode 100644 index 0000000..5f452d8 --- /dev/null +++ b/node/README.md @@ -0,0 +1,3 @@ +# Node + +An Alpine image for scripting with node and git using a dumb-init entrypoint. diff --git a/snapraid/.dockerignore b/snapraid/.dockerignore new file mode 100644 index 0000000..b43bf86 --- /dev/null +++ b/snapraid/.dockerignore @@ -0,0 +1 @@ +README.md diff --git a/snapraid/Dockerfile b/snapraid/Dockerfile new file mode 100644 index 0000000..e0fddf9 --- /dev/null +++ b/snapraid/Dockerfile @@ -0,0 +1,14 @@ +FROM alpine:latest + +RUN apk --update add bash python3 git smartmontools tzdata curl jq dumb-init && \ + apk add snapraid --update-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing --allow-untrusted && \ + git clone https://github.com/Chronial/snapraid-runner.git /app/snapraid-runner && \ + chmod +x /app/snapraid-runner/snapraid-runner.py && \ + rm -rf /var/cache/apk/* + +VOLUME /config + +ENTRYPOINT ["/usr/bin/dumb-init", "--"] +COPY start.sh /start.sh +RUN chmod 755 /start.sh +CMD ["/start.sh"] diff --git a/snapraid/README.md b/snapraid/README.md new file mode 100644 index 0000000..1798679 --- /dev/null +++ b/snapraid/README.md @@ -0,0 +1,34 @@ +# SnapRAID + +This [SnapRAID](https://www.snapraid.it/) image uses a python [runner](https://github.com/Chronial/snapraid-runner) to automate the backup syncs. Bash, curl, jq and dumb-init entrypoint are also available. + +```sh +docker create -d \ + -v /mnt:/mnt \ + # https://github.com/amadvance/snapraid/blob/master/snapraid.conf.example + -v snapraid.conf:/config/snapraid.conf + # https://github.com/Chronial/snapraid-runner/blob/master/snapraid-runner.conf.example + -v snapraid-runner.conf:/config/snapraid-runner.conf + -e POST_COMMANDS_SUCCESS "curl -d 'Backup successful 😀' ntfy.sh/mytopic" + --name snapraid + ghcr.io/brettinternet/snapraid +``` + +Also available in the `entrypoint.sh` are slots for pre and post commands: + +```yaml +PRE_COMMANDS: |- + curl -d "Oh boy, here we go again..." https://healthchecks.io/start + +POST_COMMANDS_SUCCESS: |- + curl -d "We backed it up!" ntfy.sh/mytopic + +POST_COMMANDS_FAILURE: |- + /config/mail-failure.sh + +POST_COMMANDS_INCOMPLETE: |- + /config/uh-oh.sh + +POST_COMMANDS_EXIT: |- + docker start my_container +``` diff --git a/snapraid/start.sh b/snapraid/start.sh new file mode 100644 index 0000000..6717ba6 --- /dev/null +++ b/snapraid/start.sh @@ -0,0 +1,69 @@ +#!/bin/sh + +### Validation and Setup + +# remove default configuration +if [ ! -L /etc/snapraid.conf ] && [ -f /etc/snapraid.conf ]; then + rm /etc/snapraid.conf +fi + +# Verify user config present +if [ ! -f /config/snapraid.conf ]; then + echo "No config found. You must configure SnapRAID before running this container." + exit 1 +fi + +# Verify user runner config present +if [ ! -f /config/snapraid-runner.conf ]; then + echo "No config found. You must configure snapraid-runner before running this container" + exit 1 +fi + +# Link user config to expected snapraid config location +if [ ! -L /etc/snapraid.conf ]; then + ln -s /config/snapraid.conf /etc/snapraid.conf +fi + +### Declarations + +function run_commands { + COMMANDS=$1 + while IFS= read -r cmd; do echo "$cmd" && eval "$cmd" ; done < <(printf '%s\n' "$COMMANDS") +} + +function run_exit_commands { + set +e + set +o pipefail + run_commands "${POST_COMMANDS_EXIT:-}" +} + +### Runtime + +trap run_exit_commands EXIT + +run_commands "${PRE_COMMANDS:-}" + +start=$(date +%s) +echo Starting SnapRAID runner at $(date +"%Y-%m-%d %H:%M:%S") + +set +e +/usr/bin/python3 /app/snapraid-runner/snapraid-runner.py -c /config/snapraid-runner.conf +RC=$? +set -e + +if [ $RC -ne 0 ]; then + if [ $RC -eq 3 ] && [ -n "${POST_COMMANDS_INCOMPLETE:-}" ]; then + run_commands "${POST_COMMANDS_INCOMPLETE:-}" + else + run_commands "${POST_COMMANDS_FAILURE:-}" + fi +fi + +echo Runner successful + +end=$(date +%s) +echo Finished SnapRAID runner at $(date +"%Y-%m-%d %H:%M:%S") after $((end-start)) seconds + +[ $RC -ne 0 ] && exit $RC + +run_commands "${POST_COMMANDS_SUCCESS:-}"