From 9ac1b503cea23242576a6fe5c3446ea1a40a98a7 Mon Sep 17 00:00:00 2001 From: Deepak Tiwari Date: Mon, 4 Nov 2024 16:46:57 +0530 Subject: [PATCH] Creating docker image for repositopry-snapshot --- .github/workflows/repository-snapshot.yaml | 44 ++++++++++++++++++++++ repository-snapshot/Dockerfile | 32 ++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 .github/workflows/repository-snapshot.yaml create mode 100644 repository-snapshot/Dockerfile diff --git a/.github/workflows/repository-snapshot.yaml b/.github/workflows/repository-snapshot.yaml new file mode 100644 index 0000000..520cabe --- /dev/null +++ b/.github/workflows/repository-snapshot.yaml @@ -0,0 +1,44 @@ +name: Build and Push Docker Image + +on: + push: + branches: [ main ] + paths: + - 'repository-snapshot/**' + - '.github/workflows/repository-snapshot.yaml' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Generate container metadata + id: meta + uses: docker/metadata-action@v3 + with: + images: ghcr.io/obmondo/dockerfiles/repository-snapshot + tags: | + type=semver,pattern={{version}},value=v1.0.0 + flavor: | + latest=false + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build & push container image + id: docker_build + uses: docker/build-push-action@v2 + with: + context: ./repository-mirror + labels: ${{ steps.meta.outputs.labels }} + push: true + tags: ${{ steps.meta.outputs.tags }} diff --git a/repository-snapshot/Dockerfile b/repository-snapshot/Dockerfile new file mode 100644 index 0000000..fb38e8b --- /dev/null +++ b/repository-snapshot/Dockerfile @@ -0,0 +1,32 @@ +# Use the specified base image +FROM ubuntu:24.04 + +# Installing dependencies +RUN apt-get update && apt-get install -y \ + coreutils \ + curl \ + createrepo-c \ + cron \ + debianutils \ + wget \ + rsync + +# Adding Enableit repo and key +RUN wget https://repos.obmondo.com/packagesign/public/apt/pubkey.gpg -O /etc/apt/keyrings/obmondo_custom.asc +RUN echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/obmondo_custom.asc] https://repos.obmondo.com/packagesign/public/apt noble main" | tee -a /etc/apt/sources.list.d/obmondo_custom.list + +# Installing obmondo-scripts-common and obmondo-repository-mirror +RUN apt-get update && apt-get install -y \ + obmondo-scripts-common \ + obmondo-repository-mirror + +# Create a crontab file for the scheduled job +RUN echo "0 2 * * 0 /usr/local/bin/snapshot_repo >> /var/log/snapshot_repo.log 2>&1" > /etc/cron.d/snapshot_repo && \ + chmod 0644 /etc/cron.d/snapshot_repo + +# Apply cron job and create log file +RUN crontab /etc/cron.d/snapshot_repo && \ + touch /var/log/snapshot_repo.log + +# Start the cron service +CMD ["cron", "-f"]