Skip to content

Commit 32b3f94

Browse files
authored
Merge pull request #4 from testdrivenio/updates
updates
2 parents d63d23c + 28fe908 commit 32b3f94

22 files changed

Lines changed: 64 additions & 92 deletions

.github/workflows/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Continuous Integration and Delivery
33
on: [push]
44

55
env:
6-
IMAGE: docker.pkg.github.com/$GITHUB_REPOSITORY/foo
6+
IMAGE: docker.pkg.github.com/$(echo $GITHUB_REPOSITORY | tr '[A-Z]' '[a-z]')/summarizer
77

88
jobs:
99

@@ -78,23 +78,23 @@ jobs:
7878
-p 5003:8765 \
7979
${{ env.IMAGE }}-final:latest
8080
- name: Install requirements
81-
run: docker exec fastapi-tdd pip install black flake8 isort pytest
81+
run: docker exec fastapi-tdd pip install black==20.8b1 flake8===3.8.4 isort==5.6.4 pytest==6.2.0
8282
- name: Pytest
8383
run: docker exec fastapi-tdd python -m pytest .
8484
- name: Flake8
8585
run: docker exec fastapi-tdd python -m flake8 .
8686
- name: Black
8787
run: docker exec fastapi-tdd python -m black . --check
8888
- name: isort
89-
run: docker exec fastapi-tdd /bin/sh -c "python -m isort ./*/*.py --check-only"
89+
run: docker exec fastapi-tdd python -m isort . --check-only
9090

9191
deploy:
9292
name: Deploy to Heroku
9393
runs-on: ubuntu-latest
9494
needs: [build, test]
9595
env:
96-
HEROKU_APP_NAME: salty-fortress-93778
97-
HEROKU_REGISTRY_IMAGE: registry.heroku.com/${HEROKU_APP_NAME}/foo
96+
HEROKU_APP_NAME: secret-crag-02876
97+
HEROKU_REGISTRY_IMAGE: registry.heroku.com/${HEROKU_APP_NAME}/summarizer
9898
steps:
9999
- name: Checkout master
100100
uses: actions/checkout@v2.3.4

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
__pycache__
22
env
3-
.coverage
43
htmlcov
4+
.coverage

docker-compose.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '3.7'
1+
version: '3.8'
22

33
services:
44

@@ -8,7 +8,7 @@ services:
88
volumes:
99
- ./project:/usr/src/app
1010
ports:
11-
- 8002:8000
11+
- 8004:8000
1212
environment:
1313
- ENVIRONMENT=dev
1414
- TESTING=0
@@ -17,7 +17,6 @@ services:
1717
depends_on:
1818
- web-db
1919

20-
2120
web-db:
2221
build:
2322
context: ./project/db

project/.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ env
22
.dockerignore
33
Dockerfile
44
Dockerfile.prod
5-
.coverage
65
htmlcov
6+
.coverage

project/Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# pull official base image
2-
FROM python:3.8.3-slim-buster
2+
FROM python:3.9.0-slim-buster
33

44
# set working directory
55
WORKDIR /usr/src/app
66

7-
# set environment varibles
7+
# set environment variables
88
ENV PYTHONDONTWRITEBYTECODE 1
99
ENV PYTHONUNBUFFERED 1
1010

@@ -22,5 +22,9 @@ RUN pip install -r requirements-dev.txt
2222
# add app
2323
COPY . .
2424

25+
# add entrypoint.sh
26+
COPY ./entrypoint.sh .
27+
RUN chmod +x /usr/src/app/entrypoint.sh
28+
2529
# run entrypoint.sh
2630
ENTRYPOINT ["/usr/src/app/entrypoint.sh"]

project/Dockerfile.prod

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
###########
44

55
# pull official base image
6-
FROM python:3.8.3-slim-buster as builder
6+
FROM python:3.8.6-slim-buster as builder
77

88
# install system dependencies
99
RUN apt-get update \
@@ -13,7 +13,7 @@ RUN apt-get update \
1313
# set work directory
1414
WORKDIR /usr/src/app
1515

16-
# set environment varibles
16+
# set environment variables
1717
ENV PYTHONDONTWRITEBYTECODE 1
1818
ENV PYTHONUNBUFFERED 1
1919

@@ -24,18 +24,18 @@ RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requir
2424

2525
# lint
2626
COPY . /usr/src/app/
27-
RUN pip install black flake8 isort
27+
RUN pip install black==20.8b1 flake8===3.8.4 isort==5.6.4
2828
RUN flake8 .
2929
RUN black --exclude=migrations .
30-
RUN isort ./**/*.py
30+
RUN isort .
3131

3232

3333
#########
3434
# FINAL #
3535
#########
3636

3737
# pull official base image
38-
FROM python:3.8.3-slim-buster
38+
FROM python:3.8.6-slim-buster
3939

4040
# create directory for the app user
4141
RUN mkdir -p /home/app
@@ -65,6 +65,7 @@ COPY --from=builder /usr/src/app/wheels /wheels
6565
COPY --from=builder /usr/src/app/requirements.txt .
6666
RUN pip install --upgrade pip
6767
RUN pip install --no-cache /wheels/*
68+
RUN pip install "uvicorn[standard]==0.13.1"
6869

6970
# add app
7071
COPY . .

project/app/api/crud.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# project/app/api/crud.py
2-
3-
4-
from typing import Union, List
1+
from typing import List, Union
52

63
from app.models.pydantic import SummaryPayloadSchema
74
from app.models.tortoise import TextSummary

project/app/api/ping.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
# project/app/api/ping.py
2-
3-
41
from fastapi import APIRouter, Depends
52

6-
from app.config import get_settings, Settings
7-
3+
from app.config import Settings, get_settings
84

95
router = APIRouter()
106

117

128
@router.get("/ping")
139
async def pong(settings: Settings = Depends(get_settings)):
1410
return {
15-
"ping": "pong",
11+
"ping": "pong!",
1612
"environment": settings.environment,
1713
"testing": settings.testing,
1814
}

project/app/api/summaries.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
# project/app/api/summaries.py
2-
3-
41
from typing import List
52

6-
from fastapi import APIRouter, HTTPException, Path, BackgroundTasks
3+
from fastapi import APIRouter, BackgroundTasks, HTTPException, Path
74

85
from app.api import crud
9-
from app.models.pydantic import (
6+
from app.models.tortoise import SummarySchema
7+
from app.summarizer import generate_summary
8+
9+
from app.models.pydantic import ( # isort:skip
1010
SummaryPayloadSchema,
1111
SummaryResponseSchema,
1212
SummaryUpdatePayloadSchema,
1313
)
14-
from app.models.tortoise import SummarySchema
15-
from app.summarizer import generate_summary
1614

1715

1816
router = APIRouter()

project/app/config.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
# project/app/config.py
2-
3-
41
import logging
52
import os
63
from functools import lru_cache
74

85
from pydantic import AnyUrl, BaseSettings
96

10-
log = logging.getLogger(__name__)
7+
log = logging.getLogger("uvicorn")
118

129

1310
class Settings(BaseSettings):

0 commit comments

Comments
 (0)