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.
This commit is contained in:
mmmohebi 2025-11-18 12:38:11 +03:30
parent 0c17cdb284
commit a2f8eed254
3 changed files with 33 additions and 0 deletions

4
.dockerignore Normal file
View File

@ -0,0 +1,4 @@
.idea
.venv
.git
.gitignore

28
.github/workflows/create-image.yaml vendored Normal file
View File

@ -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"

View File

@ -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