Skip to content

Commit 0b8ce90

Browse files
committed
Better docker build
1 parent 989e7c3 commit 0b8ce90

File tree

13 files changed

+71
-46
lines changed

13 files changed

+71
-46
lines changed

.github/workflows/build_and_publish.yml

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
- name: Build and push Docker image
4444
uses: docker/build-push-action@v4
4545
with:
46+
file: build/Dockerfile
4647
context: .
4748
push: true
4849
tags: ${{ steps.meta.outputs.tags }}
@@ -66,17 +67,6 @@ jobs:
6667
- name: Pull new version
6768
run: docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test
6869

69-
- name: Migrate DB
70-
run: |
71-
docker run \
72-
--rm \
73-
--network=web \
74-
--env DB_DSN=${{ secrets.DB_DSN }} \
75-
--name ${{ env.CONTAINER_NAME }}_migration \
76-
--workdir="/" \
77-
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test \
78-
alembic upgrade head
79-
8070
- name: Run new version
8171
id: run_test
8272
run: |
@@ -158,19 +148,8 @@ jobs:
158148
- name: Pull new version
159149
run: docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
160150

161-
- name: Migrate DB
162-
run: |
163-
docker run \
164-
--rm \
165-
--network=web \
166-
--env DB_DSN=${{ secrets.DB_DSN }} \
167-
--name ${{ env.CONTAINER_NAME }}_migration \
168-
--workdir="/" \
169-
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
170-
alembic upgrade head
171-
172151
- name: Run new version
173-
id: run_test
152+
id: run_prod
174153
run: |
175154
docker stop ${{ env.CONTAINER_NAME }} || true && docker rm ${{ env.CONTAINER_NAME }} || true
176155
docker run \

.vscode/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"python.testing.pytestArgs": [
3+
"tests"
4+
],
5+
"python.testing.unittestEnabled": false,
6+
"python.testing.pytestEnabled": true
7+
}

Dockerfile

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

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
SHELL := /bin/bash
22

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

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

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

2730
migrate:
2831
source ./venv/bin/activate && alembic upgrade head

auth_backend/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import os
22

33

4-
__version__ = os.getenv('APP_VERSION', 'dev')
4+
__version__ = os.getenv('APP_VERSION', 'v0.0.0-dev')

auth_backend/schemas/models.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,11 @@ class Session(Base):
135135
is_unbounded: bool | None = None
136136
session_scopes: list[Scope] | None = None
137137
last_activity: datetime
138-
138+
# JWT OIDC Fields
139+
expires_in: int
140+
access_token: str
141+
refresh_token: int
142+
token_type: str
139143

140144
class SessionPost(Base):
141145
session_name: str | None = None

cleanupdb.sh

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

deploy/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.11
2+
ARG APP_VERSION=v0.0.0-dev
3+
ENV APP_VERSION=${APP_VERSION}
4+
ENV APP_NAME=auth_backend
5+
ENV APP_MODULE=${APP_NAME}.routes.base:app
6+
7+
# Копируем файлы зависимостей и устанавливаем их
8+
COPY ./requirements.txt /app/
9+
RUN pip install -U -r /app/requirements.txt
10+
11+
# Копируем сопуствующие файлы
12+
COPY ./deploy/prestart.sh ./deploy/logging_dev.conf ./deploy/logging_test.conf ./deploy/logging_prod.conf ./migrations ./alembic.ini /app/
13+
14+
# Копируем сам проект
15+
COPY ./${APP_NAME} /app/${APP_NAME}

0 commit comments

Comments
 (0)