Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sintef/fastapi-template
FastAPI/Python Service Template
https://github.com/sintef/fastapi-template
Last synced: about 2 months ago
JSON representation
FastAPI/Python Service Template
- Host: GitHub
- URL: https://github.com/sintef/fastapi-template
- Owner: SINTEF
- License: mit
- Created: 2021-06-06T10:26:41.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-03-04T06:27:35.000Z (10 months ago)
- Last Synced: 2024-03-04T07:35:32.175Z (10 months ago)
- Language: Python
- Size: 19.5 KB
- Stars: 6
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FastAPI/Python Service Template
This is a template for building modular web services with a
best-practise organization of files using the FastAPI web framework.## Run in Docker
### Development target
The development target will allow for automatic reloading when source code changes. This requires that the local directory is bind-mounted using the -v or --volume argument. To Build and run the development target from the command line:docker build --rm -q -f Dockerfile \
--label "sintef.fastservice-target=development" \
--target development \
-t "sintef/fastservice-development:latest" .
docker run --rm -i --user="$(id -u):$(id -g)" -p 8080:8080 -v "$PWD:/app" sintef/fastservice-development:latestOpen http://localhost:8080 on your browser to test the application.
### Production target
The production target will not reload itself on code change and will run a predictable version of the code on port 80. Also you might want to use a named container with the --restart=always option to ensure that the container is restarted indefinately regardless of the exit status. To build and run the production target from the command line:docker build --rm -q -f Dockerfile \
--label "sintef.fastservice-target=production" \
--target production \
-t "sintef/fastservice-production:latest" .
docker run -d -p 80:80 --user="$(id -u):$(id -g)" --name fastservice --restart=always sintef/fastservice-production:latest