Skip to content

Deployment

Note

All project development, testing, and deployment are done in windows10/11. docker-compose*.yml may need to be changed for linux/mac environment

Note

Docker should be installed

Pull the repository

git clone https://github.com/benlau6/fastapi-fullstack.git
cd fastapi-fullstack

Dev/test stage

Note

Strongly recommended for development / testing

Note

Build command must be rerun if dockerfile / docker-compose.yml is changed.

e.g. dev -> prod or code changes

  • Single server
  • Apply code changes automatically
docker-compose build
docker-compose up

Prod stage

  • Multiple servers
docker-compose -f docker-compose.yml -f docker-compose.prod.yml build
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up

Check api status

Browse http://127.0.0.1/api/status

The following response should be shown:

{"status":"OK"}

Optional commands

Offline deployment

  1. Save the built images to .tar

    docker save -o fastapi-fullstack.tar fastapi-fullstack_api fastapi-fullstack_frontendtraefik
    
  2. Send the .tar to the offline server

    docker load -i fastapi-fullstack.tar
    

Run servers in backend

docker-compose up -d

Shortcut for develpment

docker-compose down; docker-compose up --build
Back to top