3 ms·
Some thoughts on the ordering of instructions in the Dockerfile: FROM motemen/mod_perl:5.36.0-2.4.58-2.0.13 # Run apt first, so layers can be reused if the
by KronisLV 3y ago
Some thoughts on the ordering of instructions in the Dockerfile:
FROM motemen/mod_perl:5.36.0-2.4.58-2.0.13
# Run apt first, so layers can be reused if the image is built often, do not include package lists
RUN apt-get update -y && apt-get install -y wget make build-essential \
&& rm -rf /var/lib/apt/lists/*
# Installing modules/packages might also be done in the beginning (as long as they don't need other files in place)
# If you ever need something like package.json/pom.xml/Gemfile/requirements.txt etc., COPY those first)
RUN cpan -iT Plack Mojolicious
# Bigger dependencies that change less frequently can go first, for caching
COPY lib /usr/local/apache2/lib
# The rest of the configuration and app files
COPY app.psgi /app.psgi
COPY httpd.conf /usr/local/apache2/conf/httpd.conf
COPY mojolicious.conf /usr/local/apache2/conf/mojolicious.conf
EXPOSE 80
CMD ["httpd-foreground"]
From: https://docs.docker.com/build/cache/ https://docs.docker.com/build/cache/
(probably not super important unless you're doing a lot of stuff, but sometimes useful)
- oalders 3y agoVery helpful. I tend to re-run "docker build" a lot when I'm figuring stuff out. In those cases ordering can make a big difference.