Skip to content

Commit ef7aba5

Browse files
committed
build!: Refactor dependencies and CI
1 parent 185d610 commit ef7aba5

File tree

12 files changed

+1459
-36
lines changed

12 files changed

+1459
-36
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.venv
2+
.git

.github/workflows/main.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Build and Deploy
2+
3+
permissions:
4+
contents: read
5+
packages: write
6+
7+
on:
8+
push:
9+
tags:
10+
- "v*.*.*"
11+
12+
jobs:
13+
build:
14+
name: Build and Push Docker images
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Set up QEMU
21+
uses: docker/setup-qemu-action@v3
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v3
25+
26+
- name: Login to Docker Hub
27+
uses: docker/login-action@v3
28+
with:
29+
username: ${{ secrets.DOCKERHUB_USERNAME }}
30+
password: ${{ secrets.DOCKERHUB_TOKEN }}
31+
32+
- name: Login to GitHub Container Registry
33+
uses: docker/login-action@v3
34+
with:
35+
registry: ghcr.io
36+
username: ${{ github.repository_owner }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Build and push
40+
uses: docker/build-push-action@v5
41+
with:
42+
context: .
43+
push: true
44+
tags: |
45+
ghcr.io/itsamirhn/bonbast-api:latest
46+
ghcr.io/itsamirhn/bonbast-api:${{ github.ref_name }}
47+
deploy:
48+
name: Deploy API
49+
runs-on: ubuntu-latest
50+
needs:
51+
- build
52+
environment: production
53+
steps:
54+
- name: Checkout
55+
uses: actions/checkout@v4
56+
- name: Deploy to server
57+
uses: easingthemes/ssh-deploy@main
58+
with:
59+
SSH_PRIVATE_KEY: ${{ secrets.SSH_KEY }}
60+
REMOTE_HOST: ${{ secrets.SSH_HOST }}
61+
REMOTE_USER: ${{ secrets.SSH_USERNAME }}
62+
SOURCE: docker-compose.yaml
63+
SCRIPT_AFTER: |
64+
TAG=${{ github.ref_name }} docker compose up -d

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,4 +219,5 @@ dmypy.json
219219
# Cython debug symbols
220220
cython_debug/
221221

222-
.deta
222+
.secrets
223+
.pdm-python

.pre-commit-config.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
exclude: migrations
2+
repos:
3+
- repo: https://github.com/pdm-project/pdm
4+
rev: 2.15.3
5+
hooks:
6+
- id: pdm-lock-check
7+
- repo: https://github.com/pre-commit/pre-commit-hooks
8+
rev: v4.5.0
9+
hooks:
10+
- id: check-yaml
11+
- id: mixed-line-ending
12+
- id: end-of-file-fixer
13+
- id: trailing-whitespace
14+
- id: check-merge-conflict

Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM python:3.12-slim
2+
3+
WORKDIR /code
4+
5+
COPY pyproject.toml .
6+
COPY pdm.lock .
7+
8+
RUN pip3 install "pdm<3"
9+
10+
RUN pdm install --global --project . --production --fail-fast --no-lock
11+
12+
COPY . .
13+
14+
EXPOSE 3000
15+
16+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "3000"]

Procfile

Lines changed: 0 additions & 1 deletion
This file was deleted.

docker-compose.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
services:
2+
api:
3+
image: ghcr.io/itsamirhn/bonbast-api:${TAG:-latest}
4+
restart: unless-stopped
5+
ports:
6+
- "3000:3000"

main.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,3 @@ async def read_archive_range(
132132
date = price.pop("date")
133133
price_range[date] = price
134134
return price_range
135-

pdm.lock

Lines changed: 1329 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[project]
2+
name = "Bonbast-API"
3+
version = "0.1.0"
4+
authors = [
5+
{name = "AmirMohammad Hosseini Nasab", email = "awmirhn@gmail.com"},
6+
]
7+
dependencies = [
8+
"bonbast~=1.0.2",
9+
"fastapi~=0.111.0",
10+
"fastapi-cache2~=0.2.1",
11+
"httpx~=0.27.0",
12+
"uvicorn~=0.29.0",
13+
"beautifulsoup4~=4.12.3",
14+
]
15+
requires-python = ">=3.11"
16+
readme = "README.md"
17+
license = {text = "MIT"}
18+
19+
20+
[tool.pdm]
21+
distribution = false
22+
23+
[tool.pdm.dev-dependencies]
24+
dev = [
25+
"pre-commit>=3.7.1",
26+
]

0 commit comments

Comments
 (0)