Docker on Amazon Web Services
上QQ阅读APP看书,第一时间看更新

Installing system and build dependencies

We now need to install the various system and build operating system dependencies that will support testing and building the application:

# Test stage
FROM alpine AS test
LABEL application=todobackend

# Install basic utilities
RUN apk add --no-cache bash git

# Install build dependencies
RUN apk add --no-cache gcc python3-dev libffi-dev musl-dev linux-headers mariadb-dev
RUN pip3 install wheel

 In the preceding example, we install the following dependencies:

  • Basic utilities: In Alpine Linux, the package manager is called apk, and a common pattern used in Docker images is apk add --no-cache, which installs the referenced packages and ensures the downloaded packages are not cached. We install bash, which is useful for troubleshooting, and git, which is required as we will use Git metadata later on to generate application-version tags for the Docker release image.
  • Build dependencies: Here we install the various development libraries required to build the application.  This includes gcc, python3-dev, libffi-dev, musl-dev, and linux-headers for compiling any Python C extensions and their supporting standard libraries, as well as the mariadb-dev package, which is required to build the MySQL client in the todobackend application. You also install a Python package called wheel that allows you to build Python wheels, which are a precompiled and pre-built packaging format that we will use later on.