From 44e6c41b5588ff0862b892d8e04f6c8e76970c2c Mon Sep 17 00:00:00 2001 From: Angelo Fausti Date: Tue, 10 Dec 2024 14:13:54 -0700 Subject: [PATCH] Build docker image with backup tools --- .github/workflows/ci.yaml | 32 ++++++++++++++++++++++++++++++++ Dockerfile | 30 ++++++++++++++++++++++++++++++ backup/backup.sh | 1 + 3 files changed, 63 insertions(+) create mode 100644 .github/workflows/ci.yaml create mode 100644 Dockerfile create mode 100644 backup/backup.sh diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..751488d --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,32 @@ +name: CI + +"on": + merge_group: {} + pull_request: {} + push: + tags: + - "*" + +jobs: + + build: + runs-on: ubuntu-latest + + # Only do Docker builds of tagged releases and pull requests from ticket + # branches. + if: > + startsWith(github.ref, 'refs/tags/') + || startsWith(github.head_ref, 'tickets/') + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: lsst-sqre/build-and-push-to-ghcr@v1 + id: build + with: + image: ${{ github.repository }} + github_token: ${{ secrets.GITHUB_TOKEN }} + + - run: echo Pushed ghcr.io/${{ github.repository }}:${{ steps.build.outputs.tag }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fba058a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +# Start from the InfluxDB Enterprise Meta image +# This provides the InfluxDB Enterprise influxd-ctl command +FROM influxdb:1.11.8-meta + +# Install pipx and use it to install gsutil which is required for the backup script +# to upload the backup files to Google Cloud Storage +RUN apt-get update && \ + apt-get install -y python3 python3-pip pipx && \ + pipx install gsutil && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Add pipx bin directory to PATH +ENV PATH="/root/.local/bin:$PATH" + +# Verify gsutil installation +RUN gsutil --version + +# Create a non-root user. +RUN useradd --create-home sasquatch + +# Add the backup script +COPY backup/backup.sh /usr/local/bin/backup.sh +RUN chmod +x /usr/local/bin/backup.sh + +# Switch to the non-root user. +USER sasquatch + +# Set the default command for the container +CMD ["/usr/local/bin/backup.sh"] diff --git a/backup/backup.sh b/backup/backup.sh new file mode 100644 index 0000000..6be9545 --- /dev/null +++ b/backup/backup.sh @@ -0,0 +1 @@ +echo "backup"