We use Poetry to manage dependencies and virtual environments. If you don't have it yet:
- on macOS, you can just run
brew install poetry
; - on other platforms, consult Poetry Installation.
Then:
git clone [email protected]:ElliotReeve/voltage-app.git
cd voltage-app
cp .env.example .env
# Modify .env to suit your needs, in particular, specify DATABASE_URL
poetry install
Run the server:
poetry run uvicorn app.main:app --reload
Your API documentation should show up at http://127.0.0.1:8000/docs. Server will automatically reload when you save your code – no need to restart it by hand.
Deploy:
# Build docker image
docker build --force-rm -t voltage_app .
# Save docker image
docker save -o <path for generated tar file> <image name>
# Transfer docker image to server
scp file.txt [email protected]:/remote/directory
# Load docker image
docker load -i <path to image tar file>
# Run docker container
docker run \
-itd \
--name voltage_app \
--restart=always \
-e 'DATABASE_URL=mysql+mysqldb://[email protected]/voltage' \
-p 4000:4000 \
--network=host \
voltage_app:latest