Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Infra] Docker configs #23

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion .github/workflows/lint-testing-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run pytest
run: python -m pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=app tests/ | tee pytest-coverage.txt
run: docker-compose run --rm app sh -c "python -m pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=app tests/"
- name: Pytest coverage report
id: coverageReport
uses: MishaKav/pytest-coverage-comment@main
Expand Down
26 changes: 0 additions & 26 deletions .github/workflows/python-app.yml

This file was deleted.

28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM python:3.9-alpine3.13
LABEL maintainer="github.com/vbuxbaum"

ENV PYTHONUNBUFFERED 1

COPY ./requirements.txt /tmp/requirements.txt
COPY ./dev-requirements.txt /tmp/dev-requirements.txt
COPY ./app /app
WORKDIR /app
EXPOSE 8000
# curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
ARG DEV=false
RUN echo 'starting...' && \
apk add --update build-base && \
python -m venv /py && \
/py/bin/pip install --upgrade pip setuptools wheel && \
/py/bin/pip install -r /tmp/requirements.txt && \
if [ $DEV = "true" ]; \
then /py/bin/pip install -r /tmp/dev-requirements.txt ; \
fi && \
rm -rf /tmp && \
adduser \
--disabled-password \
fastapi-user

ENV PATH="/py/bin:$PATH"

USER fastapi-user
1 change: 0 additions & 1 deletion Procfile

This file was deleted.

File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion app/main.py → app/src/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from fastapi import FastAPI

from app.routes import cards_route, rounds_route
from src.routes import cards_route, rounds_route

app = FastAPI()

Expand Down
2 changes: 1 addition & 1 deletion app/models/base_model.py → app/src/models/base_model.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pymongo.database import Database
from pymongo import MongoClient
import pydantic
from app.config import get_settings
from src.config import get_settings
from bson.objectid import ObjectId


Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pydantic import BaseModel, Field
from app.models.card_model import BingoCard
from src.models.card_model import BingoCard


class RoundPlayer(BaseModel):
Expand Down
4 changes: 2 additions & 2 deletions app/models/round_model.py → app/src/models/round_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from bson.objectid import ObjectId
from pydantic import Field

from app.models.base_model import BaseModel
from app.models.player_model import RoundPlayer
from src.models.base_model import BaseModel
from src.models.player_model import RoundPlayer


def pin_generator() -> str:
Expand Down
4 changes: 2 additions & 2 deletions app/routes/cards_route.py → app/src/routes/cards_route.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from fastapi import APIRouter, Query, HTTPException, status

from app.models.card_model import BingoCard
from app.services.card_generators import CARD_GENERATORS
from src.models.card_model import BingoCard
from src.services.card_generators import CARD_GENERATORS

router = APIRouter(prefix="/card", tags=["cards"])

Expand Down
6 changes: 3 additions & 3 deletions app/routes/rounds_route.py → app/src/routes/rounds_route.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import List
from fastapi import APIRouter, Body, Depends, HTTPException, Query, status
from app.models.round_model import RoundModel
from app.services.rounds_manager import RoundManager
from app.services.authentication import validate_token
from src.models.round_model import RoundModel
from src.services.rounds_manager import RoundManager
from src.services.authentication import validate_token

router = APIRouter(prefix="/rounds", tags=["rounds"])

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from app.config import get_settings
from src.config import get_settings


def validate_token(token: str):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Type
from frozendict import frozendict

from app.models.card_model import BingoCard, CardValues
from src.models.card_model import BingoCard, CardValues


class CardGenerator(ABC):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from fastapi.encoders import jsonable_encoder
from pymongo.results import DeleteResult

from app.models.base_model import db
from app.models.round_model import RoundModel, RoundPlayer
from app.services.card_generators import CARD_GENERATORS
from src.models.base_model import db
from src.models.round_model import RoundModel, RoundPlayer
from src.services.card_generators import CARD_GENERATORS


class RoundManager:
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/conftest.py → app/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from app.main import app
from src.main import app
from fastapi.testclient import TestClient


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from factory import Factory, Faker
from app.models.round_model import RoundModel
from src.models.round_model import RoundModel


class RoundFactory(Factory):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from app.services import authentication
from src.services import authentication


def test_token_validation(mocker, monkeypatch):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_base_model.py → app/tests/test_base_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from app.models.base_model import BaseModel
from src.models.base_model import BaseModel
import pytest


Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from app.services.card_generators import (
from src.services.card_generators import (
CardGenerator,
ClassicGenerator,
NSquareDiagGenerator,
NSquareGenerator,
)
from app.models.card_model import BingoCard
from src.models.card_model import BingoCard
from hypothesis import given, strategies as st
import pytest

Expand Down
4 changes: 2 additions & 2 deletions tests/test_cards_model.py → app/tests/test_cards_model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from app.models import card_model
from app.services import card_generators
from src.models import card_model
from src.services import card_generators


def test_compare_equal_cards():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from hypothesis import given
import hypothesis.strategies as st
from app.services.card_generators import CARD_GENERATORS
from src.services.card_generators import CARD_GENERATORS
from fastapi.testclient import TestClient


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import mongomock
from app.services.rounds_manager import RoundManager
from src.services.rounds_manager import RoundManager
from tests.factories.round_factory import RoundFactory
import pytest
from hypothesis import given, HealthCheck, settings, strategies as st
Expand Down
4 changes: 2 additions & 2 deletions tests/test_rounds_route.py → app/tests/test_rounds_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

def test_get_current_rounds(client: TestClient, mocker):
mock_get = mocker.patch(
"app.services.rounds_manager.RoundManager.get_many"
"src.services.rounds_manager.RoundManager.get_many"
)
mock_get.return_value = [round_factory.RoundFactory()]
client.get("/rounds")
Expand All @@ -13,7 +13,7 @@ def test_get_current_rounds(client: TestClient, mocker):

def test_get_round_by_id(client: TestClient, mocker):
mock_get = mocker.patch(
"app.services.rounds_manager.RoundManager.get_one_by_id"
"src.services.rounds_manager.RoundManager.get_one_by_id"
)
mock_get.return_value = round_factory.RoundFactory()
id_str = "g41ui24kg123b"
Expand Down
Loading