Set up a docker image

- Added .dockerignore, dockerfile and compose.yml + .gitea directory
This commit is contained in:
2025-09-06 01:18:56 +03:00
parent 16eccddb59
commit 873c061152
4 changed files with 109 additions and 0 deletions

14
.dockerignore Normal file
View File

@ -0,0 +1,14 @@
#.dockerignore
# Gitea
.gitea
# Docker
.dockerignore
dockerfile
compose.yaml
compose.yml
# Git
.gitignore
*.md
example.env

View File

@ -0,0 +1,48 @@
name: Build and Push Docker Image
on:
release:
types: [published]
env:
REGISTRY: git.frik.su
IMAGE_NAME: ${{ gitea.repository }}
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Docker
run: curl -fsSL https://get.docker.com | sh
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract Docker tags from release
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

36
compose.yml Normal file
View File

@ -0,0 +1,36 @@
services:
habr-article-api:
image: git.frik.su/beesquit/habr-article-api:latest
container_name: habr-article-api
ports:
- 4002:8000
environment:
DB_NAME: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
HOST_NAME: "localhost"
PG_PORT: "8000"
LOGGING_LEVEL: "INFO"
ENABLE_API_DOCS: "True"
UVI_LOGGING_LEVEL: "info"
depends_on:
postgres:
condition: service_healthy
restart: unless-stopped
postgres:
image: postgres:latest
container_name: habr-article-api-postgres
environment:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- "4001:5432"
healthcheck:
test: ["CMD", "pg_isready", "-U", "postgres"]
interval: 5s
timeout: 5s
retries: 10
restart: unless-stopped

11
dockerfile Normal file
View File

@ -0,0 +1,11 @@
FROM python:3.13-slim
WORKDIR /app
COPY . .
RUN apt-get update && apt-get install -y --no-install-recommends libpq-dev build-essential
RUN pip install --no-cache-dir -r requirements.txt
CMD ["python", "src/main.py"]