Skip to main content

How to install system packages in an application

All Divio applications are based on a Dockerfile that starts with base image that includes Linux.

If your application requires particular system packages, you can include them in the Docker image, by listing the commands required to install them - typically, using RUN apt-get - in the Dockerfile.

The commands in the Dockerfile are executed in order, so an appropriate place to put such commands is early on, after FROM - for example, after:

FROM divio/base:1.1-py3.11-slim-bullseye

and before any other commands that might depend on the package.

You should include an apt-get update in the installation commands, and run apt-get with the -y ("Say yes") option, for example:

RUN apt-get update
RUN apt-get install -y postgresql-client

to install the psql Postgres client.

To rebuild the docker image, installing the new packages:

docker compose build web

The build output will show the new RUN instructions being executed as part of your build.