Format Dockerfile/s

This commit is contained in:
hackercat
2021-02-16 13:50:52 +00:00
parent f3791102af
commit c769888e60
2 changed files with 100 additions and 96 deletions
+48 -46
View File
@@ -15,56 +15,58 @@ ARG DEBIAN_FRONTEND=noninteractive
SHELL [ "/bin/bash", "-c" ] SHELL [ "/bin/bash", "-c" ]
# > setup environment required for GitHub Actions # > setup environment required for GitHub Actions
RUN set -Eeuxo pipefail && \ RUN set -Eeuxo pipefail \
printf "Build started\n" && \ && printf "Build started\n" \
ImageOS=${DISTRIB_ID}$(echo ${DISTRIB_RELEASE} | cut -d'.' -f 1) && \ && ImageOS=${DISTRIB_ID}$(echo ${DISTRIB_RELEASE} | cut -d'.' -f 1) \
echo "IMAGE_OS=$ImageOS" | tee -a /etc/environment && \ && echo "IMAGE_OS=$ImageOS" | tee -a /etc/environment \
echo "ImageOS=$ImageOS" | tee -a /etc/environment && \ && echo "ImageOS=$ImageOS" | tee -a /etc/environment \
echo "LSB_RELEASE=${DISTRIB_RELEASE}" | tee -a /etc/environment && \ && echo "LSB_RELEASE=${DISTRIB_RELEASE}" | tee -a /etc/environment \
AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache && \ && AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache \
echo "AGENT_TOOLSDIRECTORY=$AGENT_TOOLSDIRECTORY" | tee -a /etc/environment && \ && echo "AGENT_TOOLSDIRECTORY=$AGENT_TOOLSDIRECTORY" | tee -a /etc/environment \
echo "RUN_TOOL_CACHE=$AGENT_TOOLSDIRECTORY" | tee -a /etc/environment && \ && echo "RUN_TOOL_CACHE=$AGENT_TOOLSDIRECTORY" | tee -a /etc/environment \
echo "DEPLOYMENT_BASEPATH=/opt/runner" | tee -a /etc/environment && \ && echo "DEPLOYMENT_BASEPATH=/opt/runner" | tee -a /etc/environment \
echo ". /etc/environment" | tee -a /etc/profile && \ && echo ". /etc/environment" | tee -a /etc/profile \
mkdir -p $AGENT_TOOLSDIRECTORY && \ && mkdir -p $AGENT_TOOLSDIRECTORY \
chown 1000:1000 $AGENT_TOOLSDIRECTORY && \ && chown 1000:1000 $AGENT_TOOLSDIRECTORY \
chmod 0777 $AGENT_TOOLSDIRECTORY && \ && chmod 0777 $AGENT_TOOLSDIRECTORY \
mkdir -p /github && \ && mkdir -p /github \
chown 1000:1000 /github && \ && chown 1000:1000 /github \
chmod 0777 /github && chmod 0777 /github
# > Install deps # > Install deps
RUN set -Eeuxo pipefail && \ RUN set -Eeuxo pipefail \
apt -yq update && \ && apt -yq update \
printf "Updated apt lists and upgraded packages\n\n" && \ && printf "Updated apt lists and upgraded packages\n\n" \
apt -yq install --no-install-recommends ssh lsb-release gawk jq curl git wget sudo gnupg-agent ca-certificates software-properties-common apt-transport-https libyaml-0-2 zstd unzip && \ && apt -yq install --no-install-recommends ssh lsb-release gawk jq curl git wget sudo gnupg-agent ca-certificates software-properties-common apt-transport-https libyaml-0-2 zstd unzip \
printf "Installed base utils\nInstalling docker\n" && \ && printf "Installed base utils\nInstalling docker\n" \
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - && \ && curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - \
add-apt-repository "deb https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" && \ && add-apt-repository "deb https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
apt -yq update && \ && apt -yq update \
apt -yq install docker-ce-cli && \ && apt -yq install docker-ce-cli \
printf "Cleaning image\n" && \ && printf "Cleaning image\n" \
apt-get clean && \ && apt-get clean \
rm -rf /var/lib/apt/lists/* && \ && rm -rf /var/cache/* \
rm -rf /tmp/* && \ && rm -rf /var/log/* \
printf "Cleaned up image\n" && rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/* \
&& printf "Cleaned up image\n"
# > Install Node.JS # > Install Node.JS
RUN set -Eeuxo pipefail && \ RUN set -Eeuxo pipefail \
printf "Installing Node.JS\n" && \ && printf "Installing Node.JS\n" \
curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - && \ && curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - \
DISTRO="$(lsb_release -s -c)" && \ && DISTRO="$(lsb_release -s -c)" \
echo "deb https://deb.nodesource.com/node_${NODE_VERSION}.x $DISTRO main" | tee /etc/apt/sources.list.d/nodesource.list && \ && echo "deb https://deb.nodesource.com/node_${NODE_VERSION}.x $DISTRO main" | tee /etc/apt/sources.list.d/nodesource.list \
echo "deb-src https://deb.nodesource.com/node_${NODE_VERSION}.x $DISTRO main" | tee -a /etc/apt/sources.list.d/nodesource.list && \ && echo "deb-src https://deb.nodesource.com/node_${NODE_VERSION}.x $DISTRO main" | tee -a /etc/apt/sources.list.d/nodesource.list \
apt -yq update && \ && apt -yq update \
apt -yq install --no-install-recommends nodejs="${NODE_VERSION}*" && \ && apt -yq install --no-install-recommends nodejs="${NODE_VERSION}*" \
printf "Installed Node.JS $(node -v)\n" && \ && printf "Installed Node.JS $(node -v)\n" \
dpkg-query -f '${binary:Package}\n' -W && \ && dpkg-query -f '${binary:Package}\n' -W \
printf "Cleaning image\n" && \ && printf "Cleaning image\n" \
apt-get clean && \ && apt-get clean \
rm -rf /var/lib/apt/lists/* && \ && rm -rf /var/lib/apt/lists/* \
rm -rf /tmp/* && \ && rm -rf /tmp/* \
printf "Cleaned up image\n" && printf "Cleaned up image\n"
# > Home repository # > Home repository
LABEL org.opencontainers.image.source="https://github.com/catthehacker/docker_images" LABEL org.opencontainers.image.source="https://github.com/catthehacker/docker_images"
+52 -50
View File
@@ -18,58 +18,60 @@ ARG DEBIAN_FRONTEND=noninteractive
SHELL [ "/bin/bash", "-c" ] SHELL [ "/bin/bash", "-c" ]
# > setup environment required for GitHub Actions # > setup environment required for GitHub Actions
RUN set -Eeuxo pipefail && \ RUN set -Eeuxo pipefail \
printf "Build started\n" && \ && printf "Build started\n" \
ImageOS=${DISTRIB_ID}$(echo ${DISTRIB_RELEASE} | cut -d'.' -f 1) && \ && ImageOS=${DISTRIB_ID}$(echo ${DISTRIB_RELEASE} | cut -d'.' -f 1) \
echo "IMAGE_OS=$ImageOS" | tee -a /etc/environment && \ && echo "IMAGE_OS=$ImageOS" | tee -a /etc/environment \
echo "ImageOS=$ImageOS" | tee -a /etc/environment && \ && echo "ImageOS=$ImageOS" | tee -a /etc/environment \
echo "LSB_RELEASE=${DISTRIB_RELEASE}" | tee -a /etc/environment && \ && echo "LSB_RELEASE=${DISTRIB_RELEASE}" | tee -a /etc/environment \
AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache && \ && AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache \
echo "AGENT_TOOLSDIRECTORY=$AGENT_TOOLSDIRECTORY" | tee -a /etc/environment && \ && echo "AGENT_TOOLSDIRECTORY=$AGENT_TOOLSDIRECTORY" | tee -a /etc/environment \
echo "RUN_TOOL_CACHE=$AGENT_TOOLSDIRECTORY" | tee -a /etc/environment && \ && echo "RUN_TOOL_CACHE=$AGENT_TOOLSDIRECTORY" | tee -a /etc/environment \
echo "RUNNER_USER=${RUNNER_USER}" | tee -a /etc/environment && \ && echo "DEPLOYMENT_BASEPATH=/opt/runner" | tee -a /etc/environment \
echo "RUNNER_TEMP=/home/${RUNNER_USER}/work/_temp" | tee -a /etc/environment && \ && echo ". /etc/environment" | tee -a /etc/profile \
echo "DEPLOYMENT_BASEPATH=/opt/runner" | tee -a /etc/environment && \ && mkdir -p $AGENT_TOOLSDIRECTORY \
echo ". /etc/environment" | tee -a /etc/profile && \ && chown 1000:1000 $AGENT_TOOLSDIRECTORY \
mkdir -p $AGENT_TOOLSDIRECTORY && \ && chmod 0777 $AGENT_TOOLSDIRECTORY \
chown 1000:1000 $AGENT_TOOLSDIRECTORY && \ && mkdir -p /github \
chmod 0777 $AGENT_TOOLSDIRECTORY && \ && chown 1000:1000 /github \
mkdir -p /github && \ && chmod 0777 /github \
chown 1000:1000 /github && \ && echo "RUNNER_USER=${RUNNER_USER}" | tee -a /etc/environment \
chmod 0777 /github && echo "RUNNER_TEMP=/home/${RUNNER_USER}/work/_temp" | tee -a /etc/environment
# > Install deps # > Install deps
RUN set -Eeuxo pipefail && \ RUN set -Eeuxo pipefail \
apt -yq update && \ && apt -yq update \
printf "Updated apt lists and upgraded packages\n\n" && \ && printf "Updated apt lists and upgraded packages\n\n" \
apt -yq install --no-install-recommends ssh lsb-release gawk jq curl git wget sudo gnupg-agent ca-certificates software-properties-common apt-transport-https libyaml-0-2 zstd unzip && \ && apt -yq install --no-install-recommends ssh lsb-release gawk jq curl git wget sudo gnupg-agent ca-certificates software-properties-common apt-transport-https libyaml-0-2 zstd unzip \
printf "Installed base utils\nInstalling docker\n" && \ && printf "Installed base utils\nInstalling docker\n" \
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - && \ && curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - \
add-apt-repository "deb https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" && \ && add-apt-repository "deb https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
apt -yq update && \ && apt -yq update \
apt -yq install docker-ce-cli && \ && apt -yq install docker-ce-cli \
printf "Cleaning image\n" && \ && printf "Cleaning image\n" \
apt-get clean && \ && apt-get clean \
rm -rf /var/lib/apt/lists/* && \ && rm -rf /var/cache/* \
rm -rf /tmp/* && \ && rm -rf /var/log/* \
printf "Cleaned up image\n" && rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/* \
&& printf "Cleaned up image\n"
# > Install Node.JS # > Install Node.JS
RUN set -Eeuxo pipefail && \ RUN set -Eeuxo pipefail \
printf "Installing Node.JS\n" && \ && printf "Installing Node.JS\n" \
curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - && \ && curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - \
DISTRO="$(lsb_release -s -c)" && \ && DISTRO="$(lsb_release -s -c)" \
echo "deb https://deb.nodesource.com/node_${NODE_VERSION}.x $DISTRO main" | tee /etc/apt/sources.list.d/nodesource.list && \ && echo "deb https://deb.nodesource.com/node_${NODE_VERSION}.x $DISTRO main" | tee /etc/apt/sources.list.d/nodesource.list \
echo "deb-src https://deb.nodesource.com/node_${NODE_VERSION}.x $DISTRO main" | tee -a /etc/apt/sources.list.d/nodesource.list && \ && echo "deb-src https://deb.nodesource.com/node_${NODE_VERSION}.x $DISTRO main" | tee -a /etc/apt/sources.list.d/nodesource.list \
apt -yq update && \ && apt -yq update \
apt -yq install --no-install-recommends nodejs="${NODE_VERSION}*" && \ && apt -yq install --no-install-recommends nodejs="${NODE_VERSION}*" \
printf "Installed Node.JS $(node -v)\n" && \ && printf "Installed Node.JS $(node -v)\n" \
dpkg-query -f '${binary:Package}\n' -W && \ && dpkg-query -f '${binary:Package}\n' -W \
printf "Cleaning image\n" && \ && printf "Cleaning image\n" \
apt-get clean && \ && apt-get clean \
rm -rf /var/lib/apt/lists/* && \ && rm -rf /var/lib/apt/lists/* \
rm -rf /tmp/* && \ && rm -rf /tmp/* \
printf "Cleaned up image\n" && printf "Cleaned up image\n"
# > Create non-root user # > Create non-root user
RUN set -Eeuxo pipefail && \ RUN set -Eeuxo pipefail && \
@@ -89,9 +91,9 @@ LABEL org.opencontainers.image.source="https://github.com/catthehacker/docker_im
# > Don't run as root, generally not good idea # > Don't run as root, generally not good idea
USER ${RUNNER_USER}:${RUNNER_USER} USER ${RUNNER_USER}:${RUNNER_USER}
SHELL [ "/bin/bash", "--login" ]
WORKDIR /home/runner WORKDIR /home/runner
SHELL [ "/bin/bash", "--login" ]
# > Force bash with environment # > Force bash with environment
ENTRYPOINT [ "/bin/bash", "--login" ] ENTRYPOINT [ "/bin/bash", "--login" ]