Dockerize my rusty vertigo app

A vertigo app consists of two parts: the build created by vertigo build (WebAssembly, JavaScript and static files) and the vertigo server, which serves the build and renders pages on the server side. The sfisol/vertigo image already contains the server, so the image of the app only needs to add the build.

Build the app on your machine or in CI:

vertigo build

and put a Dockerfile next to Cargo.toml:

FROM sfisol/vertigo:0.13

COPY ./build build/

EXPOSE 4444

CMD ["./vertigo", "serve", "--dest-dir", "build", "--host", "0.0.0.0", "--port", "4444"]

Use the image version matching the version of vertigo in your Cargo.toml - the server and the app need to talk the same language.

Add a .dockerignore, so the target directory isn't sent to Docker on every build:

.git
target

Then build and run the image:

docker build -t my-app .
docker run -p 4444:4444 my-app

Configuration

Options like --env or --mount-point (see "Runtime configuration" and "Serving under a sub-path") can be set when starting a container, by replacing the command:

docker run -p 4444:4444 my-app ./vertigo serve --dest-dir build --host 0.0.0.0 --port 4444 --env api_url=https://api.example.com

To make them configurable with environment variables of the container instead, run the server through a shell:

ENV API_URL=/api

CMD ["/bin/sh", "-c", "./vertigo serve --dest-dir build --host 0.0.0.0 --port 4444 --env api_url=$API_URL"]
docker run -p 4444:4444 -e API_URL=https://api.example.com my-app