Last active
June 10, 2020 19:31
-
-
Save awnion/0624447157dd9540b5e19e0fd2fef3bf to your computer and use it in GitHub Desktop.
Dockerfile expamples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Credits: https://github.com/moby/moby/issues/16058#issuecomment-334370727 | |
# Example with apt-get update, install and clean it's cache | |
RUN apt-get update -yq \ | |
&& DEBIAN_FRONTEND=noninteractive \ | |
apt-get install -yq pkg1 pkg2 pkg3 \ | |
&& find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete | |
# Example with many packages to install at one time | |
RUN apt-get update -yq \ | |
&& DEBIAN_FRONTEND=noninteractive \ | |
apt-get install -yq \ | |
pkg1 \ | |
pkg2 \ | |
pkg3 \ | |
... \ | |
pkg10 \ | |
&& find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete | |
# Example untar with pipes | |
ARG WEBSOCKIFY_VERSION="v0.8.0" | |
RUN mkdir -p /opt/websockify \ | |
&& curl -sSL https://github.com/novnc/websockify/archive/${WEBSOCKIFY_VERSION}.tar.gz \ | |
| tar -zx -C /opt/websockify --strip 1 | |
# Example unzip without pipes and fixing files permissions | |
ARG BROWSERMOB_PROXY_VERSION=2.1.0-beta-3 | |
RUN apt-install --no-install-recommends openjdk-8-jre \ | |
&& curl -sSLo /tmp/browsermob-proxy-bin.zip \ | |
https://github.com/lightbody/browsermob-proxy/releases/download/browsermob-proxy-${BROWSERMOB_PROXY_VERSION}/browsermob-proxy-${BROWSERMOB_PROXY_VERSION}-bin.zip \ | |
&& unzip /tmp/browsermob-proxy-bin.zip -d /opt/ \ | |
&& chown -R 0:0 "/opt/browsermob-proxy-${BROWSERMOB_PROXY_VERSION}/" \ | |
&& find "/opt/browsermob-proxy-${BROWSERMOB_PROXY_VERSION}/" -type d -print0 | xargs -r -0 chmod 0755 \ | |
&& find "/opt/browsermob-proxy-${BROWSERMOB_PROXY_VERSION}/" -type f -print0 | xargs -r -0 chmod 0644 \ | |
&& chmod a+x "/opt/browsermob-proxy-${BROWSERMOB_PROXY_VERSION}/bin/browsermob-proxy" \ | |
&& ln -sfn "/opt/browsermob-proxy-${BROWSERMOB_PROXY_VERSION}/" /opt/browsermob-proxy \ | |
&& rm -f /tmp/browsermob-proxy-bin.zip | |
# Example call command with many arguments at one time (my propose is use long parameters names) | |
RUN some-command1 \ | |
--some-option1=some-value1 \ | |
--some-option2=some-value2 \ | |
--some-option2=some-value2 \ | |
--some-option2=some-value2 \ | |
&& some-command2 \ | |
--some-option1=some-value1 \ | |
--some-option2=some-value2 \ | |
--some-option2=some-value2 \ | |
--some-option2=some-value2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment