Files
ODrive/Dockerfile
T
SZEDER Gábor 22226faef4 Dockerfile: avoid caching issues with apt-get update and install
The `Dockerfile` uses separate `RUN` instructions for each `apt-get`
command.  Docker's documentation considers this as an anti-pattern,
because it can lead to caching issues [1].

Follow Docker's advice, and combine all `apt-get` invocations into a
single `RUN` instruction with an &&-chaned list of commands.  This
makes it rather hard to tell which command produces which output, so
insert a `set -x` at the beginning of the command chain to generate a
trace of the executed commands.

[1] Each `RUN` instruction, including subsequent `RUN apt-get update`
    and `RUN apt-get install` instructions create separate layers that
    are stored in the Docker cache.  If someone were to modify the
    list of list of packages to install, then Docker would re-use the
    layer created by the prior `RUN apt-get update` instruction,
    meaning that `apt-get install` would use an outdate package list.
    This can lead to outdated packages to be installed, or a failure
    if the outdated version is not present anymore in the package
    repository.

    https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#run
2022-02-20 19:34:48 +01:00

40 lines
1.3 KiB
Docker

FROM ubuntu:bionic
# Prepare the build environment and dependencies
RUN \
set -x && \
apt-get update && \
apt-get -y install software-properties-common && \
add-apt-repository ppa:team-gcc-arm-embedded/ppa && \
add-apt-repository ppa:jonathonf/tup && \
apt-get update && \
apt-get -y upgrade && \
apt-get -y install gcc-arm-embedded openocd tup python3.7 python3-yaml python3-jinja2 python3-jsonschema build-essential git time && \
# Build step below does not know about debian's python naming schemme
ln -s /usr/bin/python3.7 /usr/bin/python && \
mkdir -p ODrive
WORKDIR ODrive/Firmware
# Must attach the firmware tree into the container
CMD \
# Regenerate autogen/version.c
mkdir -p autogen && \
python ../tools/odrive/version.py \
--output autogen/version.c && \
# Regenerate python interface
mkdir ../Firmware/autogen; \
python interface_generator_stub.py \
--definitions odrive-interface.yaml \
--template ../tools/enums_template.j2 \
--output ../tools/odrive/enums.py && \
python interface_generator_stub.py \
--definitions odrive-interface.yaml \
--template ../tools/arduino_enums_template.j2 \
--output ../Arduino/ODriveArduino/ODriveEnums.h && \
python ../tools/odrive/version.py --output ../Firmware/autogen/version.c && \
# Hack around Tup's dependency on FUSE
tup init && \
tup generate build.sh && \
./build.sh