Fly.io has some specific setup for PostgreSQL Docker images, which means that your best bet is to start from their base image and then customize it. Luckily, their base image is based on the official PostgreSQL repo for Ubuntu, so installing additional extensions is very easy.
-
Choose a Dockerfile from below, we've provided two examples, one for
pgvectorand another forpostgis.You can also create your own by following the same pattern, by adding the installation steps for the PostgreSQL extension you want to install.
-
Login to Docker Hub:
docker login
-
Build and push the image to Docker Hub. Replace the variables below with your own values:
username=your-dockerhub-username # the user you just logged in to Docker Hub with image_name=custom-fly-docker # or a more descriptive one, e.g. fly-postgis dockerfile=path-to-your-dockerfile # e.g. ./pgvector.Dockerfile or ./postgis.Dockerfile docker build --tag $username/$image_name --push --file $dockerfile .
-
Ready! You can now use your new image when setting up your app with Wasp deploy. Replace the variables below with your own values:
wasp deploy fly setup --db-image $username/$image_name $app_name $region