Skip to content

Commit

Permalink
Merge pull request #1 from max-pfeiffer/feature/first_release
Browse files Browse the repository at this point in the history
Feature/first release
  • Loading branch information
max-pfeiffer authored Jul 10, 2022
2 parents ea66e9f + 9d0437f commit 82acf1d
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 253 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Pipeline

on: push

jobs:
run-tests:
runs-on: ubuntu-20.04
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install Poetry
uses: abatilo/[email protected]
with:
poetry-version: 1.1.11
- name: Install dependencies
run: |
poetry config virtualenvs.in-project true
poetry install --no-root
- name: Run all tests with pytest
run: |
source .venv/bin/activate
export DOCKER_BUILDKIT=1
pytest
7 changes: 0 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,3 @@ repos:
hooks:
- id: black
language_version: python3.9
- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: system
types: [python]
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
![pipeline workflow](https://github.com/max-pfeiffer/uvicorn-poetry-project-template/actions/workflows/pipeline.yml/badge.svg)
# uvicorn-poetry-project-template
[Cookiecutter](https://github.com/cookiecutter/cookiecutter) project template for the
[uvicorn-poetry Docker image](https://github.com/max-pfeiffer/uvicorn-poetry).
Expand All @@ -18,3 +19,11 @@ Run application in project directory:
```shell
poetry run uvicorn --workers 1 --host 0.0.0.0 --port 80 app.main:app
```
Build the production Docker image:
```shell
docker build --target production-image --tag my-application:1.0.0 .
```
Run the containerized application:
```shell
docker run -it --rm my-application:1.0.0
```
224 changes: 8 additions & 216 deletions poetry.lock

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[tool.poetry]
name = "fast-api-micro-service-template"
version = "0.1.0"
version = "1.0.0"
description = "New template for spinning up a micro service"
authors = ["Max Pfeiffer <max.pfeiffer@hapimag.com>"]
authors = ["Max Pfeiffer <max.pfeiffer@maxpfeiffer.ch>"]

[tool.poetry.dependencies]
python = "3.9.*"
Expand All @@ -11,7 +11,6 @@ python = "3.9.*"
cookiecutter = "1.7.3"
pytest = "7.1.2"
pytest-cookies = "0.6.1"
pylint = "2.13.8"
black = "22.3.0"
pre-commit = "2.17.0"

Expand All @@ -21,9 +20,6 @@ testpaths = [
"tests",
]

[tool.pylint.master]
ignore-paths = "{{cookiecutter.project_slug}}"

[tool.black]
line-length = 80
target-version = ['py39']
Expand Down
5 changes: 0 additions & 5 deletions tests/test_custom_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
"""
Tests custom config
"""

from pathlib import Path

import toml
Expand All @@ -14,7 +10,6 @@ def test_custom_config(cookies) -> None:
:param cookies: cookies fixture
"""
# pylint: disable=duplicate-code
result: Result = cookies.bake(
extra_context={
"project_name": "Seriously silly pRoject naMe",
Expand Down
5 changes: 0 additions & 5 deletions tests/test_default_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
"""
Tests default config
"""

from pathlib import Path

import toml
Expand All @@ -14,7 +10,6 @@ def test_default_config(cookies) -> None:
:param cookies: cookies fixture
"""
# pylint: disable=duplicate-code
result: Result = cookies.bake()

assert result.project_path.name == "project-name"
Expand Down
7 changes: 0 additions & 7 deletions {{cookiecutter.project_slug}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,3 @@ repos:
hooks:
- id: black
language_version: python3.9
- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: system
types: [python]
8 changes: 3 additions & 5 deletions {{cookiecutter.project_slug}}/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Be aware that you need to specify these arguments before the first FROM
# see: https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
ARG BASE_IMAGE_NAME_AND_TAG=pfeiffermax/uvicorn-poetry:2.0.0-python3.9.11-slim-bullseye
ARG OFFICIAL_PYTHON_IMAGE
FROM ${BASE_IMAGE_NAME_AND_TAG} as base-image
FROM pfeiffermax/uvicorn-poetry:2.0.0-python3.9.11-slim-bullseye as base-image

WORKDIR /application_root

Expand All @@ -12,7 +10,7 @@ WORKDIR /application_root
COPY ./poetry.lock ./pyproject.toml /application_root/
RUN poetry install --no-interaction --no-root --no-dev

FROM ${OFFICIAL_PYTHON_IMAGE} as production-image
FROM python:3.9.11-slim-bullseye as production-image
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONPATH=/application_root
Expand All @@ -39,7 +37,7 @@ USER python_application

CMD ["/application_server/start_uvicorn.sh"]

FROM ${OFFICIAL_PYTHON_IMAGE} as production-image-json-logging
FROM python:3.9.11-slim-bullseye as production-image-json-logging
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONPATH=/application_root \
Expand Down
1 change: 0 additions & 1 deletion {{cookiecutter.project_slug}}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ fastapi = "0.75.2"
pytest = "6.2.5"
pytest-cov = "3.0.0"
coverage = "6.1.1"
pylint = "2.13.7"
black = "22.3.0"
pre-commit = "2.17.0"
requests = "2.27.1"
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from starlette.testclient import TestClient
from fastapi.testclient import TestClient

from app.main import app

Expand Down

0 comments on commit 82acf1d

Please sign in to comment.