Skip to content

Commit

Permalink
Creating docker image for repositopry-snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
Deepak Tiwari committed Nov 5, 2024
1 parent e50df70 commit 9ac1b50
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/repository-snapshot.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
32 changes: 32 additions & 0 deletions repository-snapshot/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit 9ac1b50

Please sign in to comment.