Skip to content

Commit

Permalink
Merge branch 'release/4.1.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
s3rius committed Apr 25, 2023
2 parents a00e0d1 + 224f41b commit 8049017
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Install deps
run: |
pip install -U pip
pip install poetry==1.2.2
pip install poetry==1.4.2
poetry install
env:
POETRY_VIRTUALENVS_CREATE: false
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ WORKDIR /src

ENV PATH ${PATH}:/home/fastapi_template/.local/bin

RUN pip install poetry==1.2.2
RUN pip install poetry==1.4.2

COPY . /src/
RUN pip install .
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ stages:
except:
- tags
before_script:
- pip install poetry==1.2.2
- pip install poetry==1.4.2
- poetry config virtualenvs.create false
- poetry install

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ If you want to develop in docker with autoreload add `-f deploy/docker-compose.d
Like this:

```bash
docker-compose -f deploy/docker-compose.yml -f deploy/docker-compose.dev.yml --project-directory . up
docker-compose -f deploy/docker-compose.yml -f deploy/docker-compose.dev.yml --project-directory . up --build
```

This command exposes the web application on port 8000, mounts current directory and enables autoreload.
Expand Down Expand Up @@ -210,8 +210,8 @@ aerich migrate
If you want to run it in docker, simply run:
```bash
docker-compose -f deploy/docker-compose.yml --project-directory . run --rm api pytest -vv .
docker-compose -f deploy/docker-compose.yml --project-directory . down
docker-compose -f deploy/docker-compose.yml -f deploy/docker-compose.dev.yml --project-directory . run --build --rm api pytest -vv .
docker-compose -f deploy/docker-compose.yml -f deploy/docker-compose.dev.yml --project-directory . down
```
For running tests on your local machine.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.9.6-slim-buster
FROM python:3.9.6-slim-buster as prod

{%- if cookiecutter.db_info.name == "mysql" %}
RUN apt-get update && apt-get install -y \
Expand All @@ -15,7 +15,7 @@ RUN apt-get update && apt-get install -y \
{%- endif %}


RUN pip install poetry==1.2.2
RUN pip install poetry==1.4.2

# Configuring poetry
RUN poetry config virtualenvs.create false
Expand All @@ -25,7 +25,7 @@ COPY pyproject.toml poetry.lock /app/src/
WORKDIR /app/src

# Installing requirements
RUN poetry install
RUN poetry install --only main

{%- if cookiecutter.db_info.name == "mysql" or cookiecutter.db_info.name == "postgresql" %}
# Removing gcc
Expand All @@ -36,6 +36,10 @@ RUN apt-get purge -y \

# Copying actuall application
COPY . /app/src/
RUN poetry install
RUN poetry install --only main

CMD ["/usr/local/bin/python", "-m", "{{cookiecutter.project_name}}"]

FROM prod as dev

RUN poetry install
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ services:
ports:
# Exposes application port.
- "8000:8000"
build:
target: dev
volumes:
# Adds current directory as volume.
- .:/app/src/
Expand All @@ -21,6 +23,6 @@ services:
command:
- taskiq
- worker
- {{cookiecutter.project_name}}.taskiq:broker
- {{cookiecutter.project_name}}.tkq:broker
- --reload
{%- endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ services:
build:
context: .
dockerfile: ./deploy/Dockerfile
target: prod
image: {{cookiecutter.project_name}}:{{"${" }}{{cookiecutter.project_name | upper }}_VERSION:-latest{{"}"}}
restart: always
env_file:
Expand Down
10 changes: 10 additions & 0 deletions fastapi_template/tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from pathlib import Path
import shlex
import subprocess
from typing import Optional
Expand Down Expand Up @@ -39,6 +40,15 @@ def run_docker_compose_command(

def run_default_check(context: BuilderContext, without_pytest=False):
generate_project_and_chdir(context)
compose = Path("./deploy/docker-compose.yml")
compose_contents = compose.read_text()
new_compose_lines = []
for line in compose_contents.splitlines():
if line.strip().replace(" ", "") == "target:prod":
continue
new_compose_lines.append(line)
compose.write_text("\n".join(new_compose_lines) + "\n")

assert run_pre_commit() == 0

if without_pytest:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "fastapi_template"
version = "4.1.2"
version = "4.1.3"
description = "Feature-rich robust FastAPI template"
authors = ["Pavel Kirilin <[email protected]>"]
packages = [{ include = "fastapi_template" }]
Expand Down

0 comments on commit 8049017

Please sign in to comment.