From a2f8eed254c22df898fd09b31877792b5d06ca4a Mon Sep 17 00:00:00 2001 From: mmmohebi Date: Tue, 18 Nov 2025 12:38:11 +0330 Subject: [PATCH] feat: Add Dockerfile, .dockerignore, and CI workflow Introduces a Dockerfile for building images, a .dockerignore file to exclude unnecessary files, and a GitHub Actions workflow for automatically building and pushing Docker images to GHCR upon release. --- .dockerignore | 4 ++++ .github/workflows/create-image.yaml | 28 ++++++++++++++++++++++++++++ Dockerfile | 1 + 3 files changed, 33 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/create-image.yaml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..581d85d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +.idea +.venv +.git +.gitignore \ No newline at end of file diff --git a/.github/workflows/create-image.yaml b/.github/workflows/create-image.yaml new file mode 100644 index 0000000..66f72dd --- /dev/null +++ b/.github/workflows/create-image.yaml @@ -0,0 +1,28 @@ +name: Deploy Images to GHCR + +on: + release: + types: [created] + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and Push Docker Image + env: + IMAGE_NAME: ${{ format('ghcr.io/{0}', github.repository) }} + run: | + docker build . --tag "${IMAGE_NAME}:${{ github.ref_name }}" + docker push "${IMAGE_NAME}:${{ github.ref_name }}" + docker tag "${IMAGE_NAME}:${{ github.ref_name }}" "${IMAGE_NAME}:latest" + docker push "${IMAGE_NAME}:latest" \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 8159c2c..26d7d03 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ FROM python:3.14-alpine +LABEL org.opencontainers.image.source="https://github.com/mrmohebi/docker-hoster" COPY requirements.txt /tmp/requirements.txt RUN pip3 install -r /tmp/requirements.txt