Skip to content

Commit 900a278

Browse files
authored
Merge pull request #2 from tiangolo/master
Aligning with tiangolo master
2 parents 059046b + 5216fcf commit 900a278

File tree

3 files changed

+31
-11
lines changed

3 files changed

+31
-11
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ After using this generator, your new project (the directory created) will contai
148148

149149
### Next release
150150

151+
* Fix locations of scripts in generated README. PR [#19](https://github.com./tiangolo/full-stack-fastapi-postgresql/pull/19) by [@ebreton](https://github.com./ebreton).
152+
153+
* Forward arguments from script to `pytest` inside container. PR [#17](https://github.com./tiangolo/full-stack-fastapi-postgresql/pull/17) by [@ebreton](https://github.com./ebreton).
154+
151155
* Update development scripts.
152156

153157
* Read Alembic configs from env vars. PR <a href="https://github.com./tiangolo/full-stack-fastapi-postgresql/pull/9" target="_blank">#9</a> by <a href="https://github.com./ebreton" target="_blank">@ebreton</a>.

{{cookiecutter.project_slug}}/README.md

+26-10
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,33 @@ Nevertheless, if it doesn't detect a change but a syntax error, it will just sto
123123
To test the backend run:
124124

125125
```bash
126-
DOMAIN=backend sh ./script-test.sh
126+
DOMAIN=backend sh ./scripts/test.sh
127127
```
128128

129-
The file `./script-test.sh` has the commands to generate a testing `docker-stack.yml` file from the needed Docker Compose files, start the stack and test it.
129+
The file `./scripts/test.sh` has the commands to generate a testing `docker-stack.yml` file from the needed Docker Compose files, start the stack and test it.
130130

131131
The tests run with Pytest, modify and add tests to `./backend/app/app/tests/`.
132132

133133
If you need to install any additional package for the tests, add it to the file `./backend/app/tests.dockerfile`.
134134

135135
If you use GitLab CI the tests will run automatically.
136136

137+
#### Test running stack
138+
139+
If your stack is already up and you just want to run the tests, you can use:
140+
141+
```bash
142+
docker-compose exec backend-tests /tests-start.sh
143+
```
144+
145+
That `/tests-start.sh` script inside the `backend-tests` container calls `pytest`. If you need to pass extra arguments to `pytest`, you can pass them to that command and they will be forwarded.
146+
147+
For example, to stop on first error:
148+
149+
```bash
150+
docker-compose exec backend-tests /tests-start.sh -x
151+
```
152+
137153
### Live development with Python Jupyter Notebooks
138154

139155
If you know about Python [Jupyter Notebooks](http://jupyter.org/), you can take advantage of them during local development.
@@ -384,7 +400,7 @@ Then you need to have those constraints in your deployment Docker Compose file f
384400
To be able to use different environments, like `prod` and `stag`, you should pass the name of the stack as an environment variable. Like:
385401

386402
```bash
387-
STACK_NAME={{cookiecutter.docker_swarm_stack_name_staging}} sh ./script-deploy.sh
403+
STACK_NAME={{cookiecutter.docker_swarm_stack_name_staging}} sh ./scripts/deploy.sh
388404
```
389405

390406
To use and expand that environment variable inside the `docker-compose.deploy.volumes-placement.yml` files you can add the constraints to the services like:
@@ -401,7 +417,7 @@ services:
401417
- node.labels.${STACK_NAME}.app-db-data == true
402418
```
403419
404-
note the `${STACK_NAME}`. In the script `./script-deploy.sh`, that `docker-compose.deploy.volumes-placement.yml` would be converted, and saved to a file `docker-stack.yml` containing:
420+
note the `${STACK_NAME}`. In the script `./scripts/deploy.sh`, that `docker-compose.deploy.volumes-placement.yml` would be converted, and saved to a file `docker-stack.yml` containing:
405421

406422
```yaml
407423
version: '3'
@@ -490,10 +506,10 @@ Here are the steps in detail:
490506
* Set these environment variables, prepended to the next command:
491507
* `TAG=prod`
492508
* `FRONTEND_ENV=production`
493-
* Use the provided `script-build.sh` file with those environment variables:
509+
* Use the provided `scripts/build.sh` file with those environment variables:
494510

495511
```bash
496-
TAG=prod FRONTEND_ENV=production bash ./script-build.sh
512+
TAG=prod FRONTEND_ENV=production bash ./scripts/build.sh
497513
```
498514

499515
2. **Optionally, push your images to a Docker Registry**
@@ -505,10 +521,10 @@ If you are using a registry and pushing your images, you can omit running the pr
505521
* Set these environment variables:
506522
* `TAG=prod`
507523
* `FRONTEND_ENV=production`
508-
* Use the provided `script-build-push.sh` file with those environment variables:
524+
* Use the provided `scripts/build-push.sh` file with those environment variables:
509525

510526
```bash
511-
TAG=prod FRONTEND_ENV=production bash ./script-build.sh
527+
TAG=prod FRONTEND_ENV=production bash ./scripts/build-push.sh
512528
```
513529

514530
3. **Deploy your stack**
@@ -518,14 +534,14 @@ TAG=prod FRONTEND_ENV=production bash ./script-build.sh
518534
* `TRAEFIK_TAG={{cookiecutter.traefik_constraint_tag}}`
519535
* `STACK_NAME={{cookiecutter.docker_swarm_stack_name_main}}`
520536
* `TAG=prod`
521-
* Use the provided `script-deploy.sh` file with those environment variables:
537+
* Use the provided `scripts/deploy.sh` file with those environment variables:
522538

523539
```bash
524540
DOMAIN={{cookiecutter.domain_main}} \
525541
TRAEFIK_TAG={{cookiecutter.traefik_constraint_tag}} \
526542
STACK_NAME={{cookiecutter.docker_swarm_stack_name_main}} \
527543
TAG=prod \
528-
bash ./script-deploy.sh
544+
bash ./scripts/deploy.sh
529545
```
530546

531547
---

{{cookiecutter.project_slug}}/backend/app/tests-start.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ set -e
33

44
python /app/app/tests_pre_start.py
55

6-
pytest /app/app/tests/
6+
pytest $* /app/app/tests/

0 commit comments

Comments
 (0)