Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
Heavybullets8 committed Oct 30, 2024
0 parents commit eda00c9
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# .github/workflows/build-and-push.yml
name: Build and Push Docker Image

on:
push:
branches:
- main
- 'v*.*.*'
workflow_dispatch:

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract version
id: vars
run: |
if [ "${GITHUB_REF_TYPE}" == "tag" ]; then
VERSION=${GITHUB_REF_NAME#refs/tags/v}
else
VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0")
fi
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: |
ghcr.io/heavybullets8/zfs-scrubber:latest
ghcr.io/heavybullets8/zfs-scrubber:${{ env.VERSION }}
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Dockerfile
FROM alpine:3.20

# Install ZFS utilities
RUN apk add --no-cache zfs

# Copy the entrypoint script
COPY entrypoint.sh /entrypoint.sh

# Make the script executable
RUN chmod +x /entrypoint.sh

# Set the entrypoint
ENTRYPOINT ["/entrypoint.sh"]
18 changes: 18 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

# entrypoint.sh
set -e

if [ -z "$ZFS_POOL" ]; then
echo "Error: No ZFS_POOL specified. Exiting."
exit 1
fi

echo "Starting scrub on pool: $ZFS_POOL"

if zpool scrub -w "$ZFS_POOL"; then
echo "Scrub failed on pool: $ZFS_POOL"
exit 1
fi

echo "Scrub completed on pool: $ZFS_POOL"

0 comments on commit eda00c9

Please sign in to comment.