Deploy with Docker
To deploy on the Writer cloud see instructions here.
You can use Docker to deploy Framework anywhere. If you’re an experienced Docker user, you may want to go straight to the provided Dockerfile.
Creating a Docker image
Verify docker installation
Make sure you have Docker installed on your system.
Navigate to your app's folder
Open a terminal and navigate to your app’s folder.
Set up Python environment
Create a pyproject.toml
file using poetry init
and install writer
using poetry add writer
.
A Dockerfile is a file with instructions that tell Docker how to build your image. It must be named 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.
To build the image, use 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.
If your image is public, anyone can now run the following command and start the app. It’s important to bind the port to a port in the host machine. The command below binds port 8080 in the Docker image to port 8080 in the host.
Go on your browser to http://localhost:8080 to check everything is working as expected.
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.
Cloud Run can be configured in just one page. It takes the image from a registry and makes it available via a URL, with SSL enabled by default. We recommend the following settings: