Skip to content

Commit 8049017

Browse files
committed
Merge branch 'release/4.1.3'
2 parents a00e0d1 + 224f41b commit 8049017

File tree

9 files changed

+29
-12
lines changed

9 files changed

+29
-12
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Install deps
3232
run: |
3333
pip install -U pip
34-
pip install poetry==1.2.2
34+
pip install poetry==1.4.2
3535
poetry install
3636
env:
3737
POETRY_VIRTUALENVS_CREATE: false

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ WORKDIR /src
2222

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

25-
RUN pip install poetry==1.2.2
25+
RUN pip install poetry==1.4.2
2626

2727
COPY . /src/
2828
RUN pip install .

fastapi_template/template/{{cookiecutter.project_name}}/.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ stages:
1010
except:
1111
- tags
1212
before_script:
13-
- pip install poetry==1.2.2
13+
- pip install poetry==1.4.2
1414
- poetry config virtualenvs.create false
1515
- poetry install
1616

fastapi_template/template/{{cookiecutter.project_name}}/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ If you want to develop in docker with autoreload add `-f deploy/docker-compose.d
3232
Like this:
3333

3434
```bash
35-
docker-compose -f deploy/docker-compose.yml -f deploy/docker-compose.dev.yml --project-directory . up
35+
docker-compose -f deploy/docker-compose.yml -f deploy/docker-compose.dev.yml --project-directory . up --build
3636
```
3737

3838
This command exposes the web application on port 8000, mounts current directory and enables autoreload.
@@ -210,8 +210,8 @@ aerich migrate
210210
If you want to run it in docker, simply run:
211211
212212
```bash
213-
docker-compose -f deploy/docker-compose.yml --project-directory . run --rm api pytest -vv .
214-
docker-compose -f deploy/docker-compose.yml --project-directory . down
213+
docker-compose -f deploy/docker-compose.yml -f deploy/docker-compose.dev.yml --project-directory . run --build --rm api pytest -vv .
214+
docker-compose -f deploy/docker-compose.yml -f deploy/docker-compose.dev.yml --project-directory . down
215215
```
216216
217217
For running tests on your local machine.

fastapi_template/template/{{cookiecutter.project_name}}/deploy/Dockerfile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.9.6-slim-buster
1+
FROM python:3.9.6-slim-buster as prod
22

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

1717

18-
RUN pip install poetry==1.2.2
18+
RUN pip install poetry==1.4.2
1919

2020
# Configuring poetry
2121
RUN poetry config virtualenvs.create false
@@ -25,7 +25,7 @@ COPY pyproject.toml poetry.lock /app/src/
2525
WORKDIR /app/src
2626

2727
# Installing requirements
28-
RUN poetry install
28+
RUN poetry install --only main
2929

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

3737
# Copying actuall application
3838
COPY . /app/src/
39-
RUN poetry install
39+
RUN poetry install --only main
4040

4141
CMD ["/usr/local/bin/python", "-m", "{{cookiecutter.project_name}}"]
42+
43+
FROM prod as dev
44+
45+
RUN poetry install

fastapi_template/template/{{cookiecutter.project_name}}/deploy/docker-compose.dev.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ services:
55
ports:
66
# Exposes application port.
77
- "8000:8000"
8+
build:
9+
target: dev
810
volumes:
911
# Adds current directory as volume.
1012
- .:/app/src/
@@ -21,6 +23,6 @@ services:
2123
command:
2224
- taskiq
2325
- worker
24-
- {{cookiecutter.project_name}}.taskiq:broker
26+
- {{cookiecutter.project_name}}.tkq:broker
2527
- --reload
2628
{%- endif %}

fastapi_template/template/{{cookiecutter.project_name}}/deploy/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ services:
55
build:
66
context: .
77
dockerfile: ./deploy/Dockerfile
8+
target: prod
89
image: {{cookiecutter.project_name}}:{{"${" }}{{cookiecutter.project_name | upper }}_VERSION:-latest{{"}"}}
910
restart: always
1011
env_file:

fastapi_template/tests/utils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
from pathlib import Path
23
import shlex
34
import subprocess
45
from typing import Optional
@@ -39,6 +40,15 @@ def run_docker_compose_command(
3940

4041
def run_default_check(context: BuilderContext, without_pytest=False):
4142
generate_project_and_chdir(context)
43+
compose = Path("./deploy/docker-compose.yml")
44+
compose_contents = compose.read_text()
45+
new_compose_lines = []
46+
for line in compose_contents.splitlines():
47+
if line.strip().replace(" ", "") == "target:prod":
48+
continue
49+
new_compose_lines.append(line)
50+
compose.write_text("\n".join(new_compose_lines) + "\n")
51+
4252
assert run_pre_commit() == 0
4353

4454
if without_pytest:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "fastapi_template"
3-
version = "4.1.2"
3+
version = "4.1.3"
44
description = "Feature-rich robust FastAPI template"
55
authors = ["Pavel Kirilin <[email protected]>"]
66
packages = [{ include = "fastapi_template" }]

0 commit comments

Comments
 (0)