Skip to content

Commit 1b85b84

Browse files
committed
added docker
1 parent 1aae94d commit 1b85b84

5 files changed

Lines changed: 83 additions & 31 deletions

File tree

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
__pycache__/
2+
*.pyc
3+
.venv/
4+
.env
5+
.git/
6+
.github/

.github/workflows/ci-cd.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: CI-CD
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [ main ]
7+
8+
jobs:
9+
ci:
10+
name: Lint + Test
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: "3.12"
21+
cache: "pip"
22+
23+
- name: Install deps
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install -r requirements.txt
27+
28+
- name: Ruff (lint)
29+
run: ruff check .
30+
31+
- name: Pytest (tests)
32+
run: pytest -q
33+
34+
docker:
35+
name: Docker Build (+ Push on main)
36+
runs-on: ubuntu-latest
37+
needs: ci
38+
39+
permissions:
40+
contents: read
41+
packages: write
42+
43+
steps:
44+
- name: Checkout code
45+
uses: actions/checkout@v4
46+
47+
- name: Setup Docker Buildx
48+
uses: docker/setup-buildx-action@v3
49+
50+
# Login only needed when pushing (main branch)
51+
- name: Login to GHCR
52+
if: github.event_name == 'push'
53+
uses: docker/login-action@v3
54+
with:
55+
registry: ghcr.io
56+
username: ${{ github.actor }}
57+
password: ${{ secrets.GITHUB_TOKEN }}
58+
59+
- name: Build (PR) or Build+Push (main)
60+
uses: docker/build-push-action@v6
61+
with:
62+
context: .
63+
push: ${{ github.event_name == 'push' }}
64+
tags: |
65+
ghcr.io/${{ github.repository }}:latest
66+
ghcr.io/${{ github.repository }}:${{ github.sha }}

.github/workflows/ci.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM python:3.14-slim
2+
3+
WORKDIR /app
4+
5+
COPY requirements.txt .
6+
RUN pip install --no-cache-dir -r requirements.txt
7+
8+
COPY . .
9+
10+
CMD ["python", "-c", "from src.app import add; print(add(2,3))"]

src/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
def add(a: int, b: int) -> int:
2-
return a + b
2+
return a + b

0 commit comments

Comments
 (0)