To deploy on the Writer cloud see instructions here.
Creating a Docker image
1
Verify docker installation
Make sure you have Docker installed on your system.
2
Navigate to your app's folder
Open a terminal and navigate to your app’s folder.
3
Set up Python environment
Create a
pyproject.toml
file using poetry init
and install writer
using poetry add writer
.Dockerfile
. You can use the following as-is, or as a starting point. It should be saved in your app’s folder, together with main.py
and .wf/
.
This Dockerfile is just a guideline.
It uses an official Python slim base image with a multistage build to reduce the size of the built image.
If you’re a Docker expert, feel free to work on your own
Dockerfile
. Framework is, after all, a standard Python package.docker build . -t
followed by an image tag, which you’re free to choose and will locally identify your image.
By default, Docker builds images in the architecture it’s being run on. If you’re working with an ARM computer, such as a Mac M2 or a Raspberry Pi, Docker will build an ARM image. Most cloud services will only accept x86 images. You can use another computer (or virtual machine) to build the image, or you can use Docker buildx.
Publishing your Docker image
Once your Docker image has been built, you can publish it to a registry. This is a place where Docker images are stored and made available to other services. We recommend using Docker Hub; it has a generous free tier, it’s very easy to set up and it’s widely supported. However, you can choose to use another service such as Azure Container Registry. To use Docker Hub, you’ll need to sign up for an account. You can push your image using the following commands.Deploying your Docker image
As mentioned earlier, once the image is a registry, it can be spun up by others. After trying a few options, we recommend using Google Cloud Run. Its free tier is generous and SSL works out of the box.
Instance specifications
Instance specifications
Minimum 0 instances, maximum 4 instances. This range is suitable unless your app needs to serve several thousands of users.
Connection settings
Connection settings
Set the request timeout to the maximum allowed and enable Session Affinity. This ensures that WebSocket connections are not unnecessarily dropped.
Resource allocation
Resource allocation
Allocate 2GB of memory and 2 vCPUs. This configuration will likely be enough to comfortably run a simple app. However, you can probably manage with much less—512MB of memory and 1 vCPU—if your app isn’t too demanding and you don’t expect much traffic.