Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 2 additions & 23 deletions .github/workflows/build_and_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
file: build/Dockerfile
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
Expand All @@ -66,17 +67,6 @@ jobs:
- name: Pull new version
run: docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test

- name: Migrate DB
run: |
docker run \
--rm \
--network=web \
--env DB_DSN=${{ secrets.DB_DSN }} \
--name ${{ env.CONTAINER_NAME }}_migration \
--workdir="/" \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test \
alembic upgrade head

- name: Run new version
id: run_test
run: |
Expand Down Expand Up @@ -158,19 +148,8 @@ jobs:
- name: Pull new version
run: docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest

- name: Migrate DB
run: |
docker run \
--rm \
--network=web \
--env DB_DSN=${{ secrets.DB_DSN }} \
--name ${{ env.CONTAINER_NAME }}_migration \
--workdir="/" \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
alembic upgrade head

- name: Run new version
id: run_test
id: run_prod
run: |
docker stop ${{ env.CONTAINER_NAME }} || true && docker rm ${{ env.CONTAINER_NAME }} || true
docker run \
Expand Down
15 changes: 0 additions & 15 deletions Dockerfile

This file was deleted.

5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
SHELL := /bin/bash

run:
source ./venv/bin/activate && uvicorn --reload --log-config logging_dev.conf auth_backend.routes.base:app
source ./venv/bin/activate && uvicorn --reload --log-config deploy/logging_dev.conf auth_backend.routes.base:app

configure: venv
source ./venv/bin/activate && pip install -r requirements.dev.txt -r requirements.txt
Expand All @@ -23,6 +23,9 @@ format:
db:
docker run -d -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust --name db-auth_api postgres:15

db-cleanup:
alembic downgrade head-"$(alembic heads | wc -l | sed 's/ //g')"
alembic upgrade head

migrate:
source ./venv/bin/activate && alembic upgrade head
Expand Down
2 changes: 1 addition & 1 deletion auth_backend/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os


__version__ = os.getenv('APP_VERSION', 'dev')
__version__ = os.getenv('APP_VERSION', 'v0.0.0-dev')
4 changes: 0 additions & 4 deletions cleanupdb.sh

This file was deleted.

15 changes: 15 additions & 0 deletions deploy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.11
ARG APP_VERSION=v0.0.0-dev
ENV APP_VERSION=${APP_VERSION}
ENV APP_NAME=auth_backend
ENV APP_MODULE=${APP_NAME}.routes.base:app

# Копируем файлы зависимостей и устанавливаем их
COPY ./requirements.txt /app/
RUN pip install -U -r /app/requirements.txt

# Копируем сопуствующие файлы
COPY ./deploy/prestart.sh ./deploy/logging_dev.conf ./deploy/logging_test.conf ./deploy/logging_prod.conf ./migrations ./alembic.ini /app/

# Копируем сам проект
COPY ./${APP_NAME} /app/${APP_NAME}
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions deploy/prestart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

alembic upgrade head
35 changes: 34 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
[project]
name = "auth_backend"
description = "REST API backend for auth"
readme = "README.md"
requires-python = ">=3.11"
keywords = []
license = {text = "Proprientary"}
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.11",
]
dynamic = ["dependencies", "optional-dependencies", "version"]

[project.urls]
Homepage = "https://git.dyakov.space/stories"
Documentation = "https://git.dyakov.space/stories/.gitea/wiki"
Repository = "https://git.dyakov.space/stories/backend"
Issues = "https://git.dyakov.space/stories/backend/issues"
Changelog = "https://git.dyakov.space/stories/backend/releases"

[build-system]
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}
optional-dependencies = {dev = { file = ["requirements.dev.txt"] }}
version = {attr = "auth_backend.__version__"}

[tool.setuptools]
packages = ["auth_backend"]

[tool.black]
line-length = 120
target-version = ['py310']
target-version = ['py311']
skip-string-normalization = true

[tool.isort]
Expand Down