Deploy FastAPI on Hostim.dev
This guide shows how to deploy a FastAPI app on Hostim.dev from a Git repository.
Quick start: Use the "FastAPI Demo" template to skip the setup.
π Open the Console Click "+ New Project", pick FastAPI Demo, and you're good to go.
Want to customize or start fresh? Follow the steps below.
0. Create a Projectβ
- Open your Hostim.dev dashboard
- Click Create Project
- Choose one:
- Scratch β start from zero
- Template β select FastAPI Demo for a ready-made setup
- Docker Compose β bring your own config
- Pick Scratch for this guide
- Name it (e.g.,
fastapi-demo
) and click Create Project
1. Use the Example FastAPI Appβ
We'll use this public repo:
π https://github.com/hostimdev/demo-fastapi
No need to clone unless you plan to run it locally. For local use, see its README.
π³ Includes working
Dockerfile
anddocker-compose.yml
2. Deploy on Hostim.devβ
β οΈ Create services in this order: Volume β Postgres β Redis β App
2.1. Create a Volume for Uploadsβ
- Go to Create Service β New Volume
- Name it
uploads-data
- Pick a plan
- Click Create Volume
2.2. Add a PostgreSQL Databaseβ
- Click Create Service β New PostgreSQL
- Name it
postgres
- Pick a plan
- Click Create PostgreSQL
2.3. Add a Redis Instanceβ
- Click Create Service β New Redis
- Name it
redis
- Pick a plan
- Click Create Redis
2.4. Create the FastAPI Appβ
- Click Create Service β New App
- Choose Git as the deployment type
- Enter:
https://github.com/hostimdev/demo-fastapi
- Branch:
main
- Dockerfile path: leave as default
- Set your plan and replicas
- Attach the volume:
- Volume:
uploads-data
- Mount path:
/app/app/static/uploads
- Volume:
- Enable HTTP and set port to
8000
- Make it public (optional)
- Click Create App
2.5. Set Up Environment Variablesβ
Go to your app's Envs tab and add:
POSTGRES_USER=$(POSTGRES_POSTGRES_USER)
POSTGRES_PASSWORD=$(POSTGRES_POSTGRES_PASSWORD)
POSTGRES_DB=$(POSTGRES_POSTGRES_DATABASE)
POSTGRES_HOST=$(POSTGRES_POSTGRES_HOST)
POSTGRES_PORT=$(POSTGRES_POSTGRES_PORT)
REDIS_HOST=$(REDIS_REDIS_HOST)
REDIS_PORT=$(REDIS_REDIS_PORT)
These pull in values automatically from the other services you set up.
Variable | Description |
---|---|
POSTGRES_* | Filled by PostgreSQL |
REDIS_* | Filled by Redis service |
Click Save Changes when done.