refactor: image building
refactor image building, add more variants
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
ARG BASEIMAGE=node
|
||||
ARG TAG=lts-alpine3.13
|
||||
FROM ${BASEIMAGE}:${TAG}
|
||||
|
||||
ARG TARGETARCH
|
||||
ARG TARGETVARIANT
|
||||
|
||||
# > ARGs before FROM are not accessible
|
||||
ARG BASEIMAGE=alpine
|
||||
ARG TAG=3.13
|
||||
ARG AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache
|
||||
ARG IMAGE_TYPE=act
|
||||
ENV ImageOS=alpine
|
||||
|
||||
|
||||
SHELL [ "/bin/ash", "-o", "pipefail", "-l", "-c" ]
|
||||
|
||||
# > setup environment required for GitHub Actions, install dependencies/packages
|
||||
RUN set -euxo pipefail \
|
||||
&& printf "Build started\nAdding environment variables\n\n" \
|
||||
&& echo "USER=$(whoami)" | tee -a /etc/environment \
|
||||
&& echo "RUNNER_USER=$(whoami)" | tee -a /etc/environment \
|
||||
&& echo "IMAGE_OS=${ImageOS}" | tee -a /etc/environment \
|
||||
&& echo "ImageOS=${ImageOS}" | tee -a /etc/environment \
|
||||
#&& echo "LSB_RELEASE=${DISTRIB_RELEASE}" | tee -a /etc/environment \
|
||||
&& echo "AGENT_TOOLSDIRECTORY=${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 ". /etc/environment" | tee -a /etc/profile \
|
||||
&& printf "Creating tool cache directory and '/github'\n\n" \
|
||||
&& mkdir -p ${AGENT_TOOLSDIRECTORY} \
|
||||
&& chown 1000:1000 ${AGENT_TOOLSDIRECTORY} \
|
||||
&& chmod 0777 ${AGENT_TOOLSDIRECTORY} \
|
||||
&& mkdir -p /github \
|
||||
&& chown 1000:1000 /github \
|
||||
&& chmod 0777 /github \
|
||||
&& printf "Installing packages\n\n" \
|
||||
&& apk --no-cache add openssh-client gawk jq curl git wget sudo gnupg ca-certificates yaml zstd zip unzip xz icu build-base python3 \
|
||||
&& printf "Creating ~/.ssh and adding 'github.com'\n\n" \
|
||||
&& mkdir -p ~/.ssh \
|
||||
&& chmod 700 ~/.ssh \
|
||||
&& ssh-keyscan github.com | tee ~/.ssh/known_hosts \
|
||||
&& printf "Installed base utils\nInstalling docker\n" \
|
||||
&& apk --no-cache add docker-cli \
|
||||
&& printf "Cleaning image\n" \
|
||||
&& apk clean cache \
|
||||
&& rm -rf /var/cache/* /var/log/* /tmp/* || echo 'Failed to delete directories' \
|
||||
&& printf "Cleaned up image\n"
|
||||
|
||||
ARG BUILD_TAG_VERSION="master"
|
||||
ARG BUILD_TAG=${IMAGE_TYPE}
|
||||
ARG BUILD_REF="master"
|
||||
|
||||
LABEL org.opencontainers.image.vendor="catthehacker"
|
||||
LABEL org.opencontainers.image.authors="me@hackerc.at"
|
||||
LABEL org.opencontainers.image.url="https://github.com/catthehacker/docker_images/tree/${BUILD_REF}/linux/${ImageOS}/${BUILD_TAG}/"
|
||||
LABEL org.opencontainers.image.source="https://github.com/catthehacker/docker_images.git"
|
||||
LABEL org.opencontainers.image.version=${BUILD_TAG_VERSION}
|
||||
LABEL org.opencontainers.image.title=${BUILD_TAG}-${TARGETARCH}-${TARGETVARIANT}
|
||||
LABEL org.opencontainers.image.revision=${BUILD_REF}
|
||||
|
||||
SHELL [ "/bin/ash", "-l", "-c" ]
|
||||
|
||||
# > Force bash with environment
|
||||
ENTRYPOINT [ "/bin/ash", "-l", "-c" ]
|
||||
@@ -0,0 +1,21 @@
|
||||
ARG BASEIMAGE=catthehacker/alpine
|
||||
ARG TAG=act
|
||||
FROM ${BASEIMAGE}:${TAG}
|
||||
|
||||
SHELL [ "/bin/ash", "-o", "pipefail", "-l", "-c" ]
|
||||
|
||||
RUN set -Eeuxo pipefail \
|
||||
&& printf "Installing Go(lang)\n" \
|
||||
&& sudo apk add --no-cache go
|
||||
|
||||
ARG BUILD_TAG_VERSION="master"
|
||||
ARG BUILD_TAG="go"
|
||||
ARG BUILD_REF="master"
|
||||
|
||||
LABEL org.opencontainers.image.vendor="catthehacker"
|
||||
LABEL org.opencontainers.image.authors="me@hackerc.at"
|
||||
LABEL org.opencontainers.image.url="https://github.com/catthehacker/docker_images/tree/${BUILD_REF}/linux/${ImageOS}/${BUILD_TAG}/"
|
||||
LABEL org.opencontainers.image.source="https://github.com/catthehacker/docker_images.git"
|
||||
LABEL org.opencontainers.image.version=${BUILD_TAG_VERSION}
|
||||
LABEL org.opencontainers.image.title=${BUILD_TAG}-${TARGETARCH}-${TARGETVARIANT}
|
||||
LABEL org.opencontainers.image.revision=${BUILD_REF}
|
||||
@@ -0,0 +1,38 @@
|
||||
ARG BASEIMAGE=catthehacker/alpine
|
||||
ARG TAG=act
|
||||
FROM ${BASEIMAGE}:${TAG}
|
||||
|
||||
SHELL [ "/bin/ash", "-o", "pipefail", "-l", "-c" ]
|
||||
|
||||
# > Create non-root user
|
||||
RUN set -Eeuxo pipefail \
|
||||
&& printf "Creating non-root user\n" \
|
||||
&& addgroup -S ${RUNNER_USER} -g 1000 && adduser -S ${RUNNER_USER} -u 1000 -G ${RUNNER_USER} -s /usr/bin/fish \
|
||||
&& sed -i /etc/sudoers -re 's/^%sudo.*/%sudo ALL=(ALL:ALL) NOPASSWD: ALL/g' \
|
||||
&& sed -i /etc/sudoers -re 's/^root.*/root ALL=(ALL:ALL) NOPASSWD: ALL/g' \
|
||||
&& sed -i /etc/sudoers -re 's/^#includedir.*/## **Removed the include directive** ##"/g' \
|
||||
&& echo "${RUNNER_USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \
|
||||
&& printf "Runner user: $(su - ${RUNNER_USER} -c id)\n" \
|
||||
&& printf "Created non-root user $(grep ${RUNNER_USER} /etc/passwd)\n" \
|
||||
&& echo "USER=${RUNNER_USER}" | tee -a /etc/environment \
|
||||
&& echo "RUNNER_USER=${RUNNER_USER}" | tee -a /etc/environment \
|
||||
&& echo "RUNNER_TEMP=/home/${RUNNER_USER}/work/_temp" | tee -a /etc/environment \
|
||||
&& mkdir -p "/home/${RUNNER_USER}/work/_temp" \
|
||||
&& chown -R ${RUNNER_USER}:${RUNNER_USER} "/home/${RUNNER_USER}/work" \
|
||||
&& mkdir -p "/home/${RUNNER_USER}/.ssh" \
|
||||
&& chmod 700 "/home/${RUNNER_USER}/.ssh" \
|
||||
&& ssh-keyscan github.com | tee "/home/${RUNNER_USER}/.ssh/known_hosts" \
|
||||
&& chmod 644 "/home/${RUNNER_USER}/.ssh/known_hosts" \
|
||||
&& chown -R ${RUNNER_USER}:${RUNNER_USER} "/home/${RUNNER_USER}/.ssh"
|
||||
|
||||
ARG BUILD_TAG_VERSION="master"
|
||||
ARG BUILD_TAG="runner"
|
||||
ARG BUILD_REF="master"
|
||||
|
||||
LABEL org.opencontainers.image.vendor="catthehacker"
|
||||
LABEL org.opencontainers.image.authors="me@hackerc.at"
|
||||
LABEL org.opencontainers.image.url="https://github.com/catthehacker/docker_images/tree/${BUILD_REF}/linux/${ImageOS}/${BUILD_TAG}/"
|
||||
LABEL org.opencontainers.image.source="https://github.com/catthehacker/docker_images.git"
|
||||
LABEL org.opencontainers.image.version=${BUILD_TAG_VERSION}
|
||||
LABEL org.opencontainers.image.title=${BUILD_TAG}-${TARGETARCH}-${TARGETVARIANT}
|
||||
LABEL org.opencontainers.image.revision=${BUILD_REF}
|
||||
@@ -0,0 +1,21 @@
|
||||
ARG BASEIMAGE=catthehacker/alpine
|
||||
ARG TAG=act
|
||||
FROM ${BASEIMAGE}:${TAG}
|
||||
|
||||
SHELL [ "/bin/ash", "-o", "pipefail", "-l", "-c" ]
|
||||
|
||||
RUN set -Eeuxo pipefail \
|
||||
&& printf "Installing Rust\n" \
|
||||
&& curl https://sh.rustup.rs -sSf | sh -s -- -y
|
||||
|
||||
ARG BUILD_TAG_VERSION="master"
|
||||
ARG BUILD_TAG="rust"
|
||||
ARG BUILD_REF="master"
|
||||
|
||||
LABEL org.opencontainers.image.vendor="catthehacker"
|
||||
LABEL org.opencontainers.image.authors="me@hackerc.at"
|
||||
LABEL org.opencontainers.image.url="https://github.com/catthehacker/docker_images/tree/${BUILD_REF}/linux/${ImageOS}/${BUILD_TAG}/"
|
||||
LABEL org.opencontainers.image.source="https://github.com/catthehacker/docker_images.git"
|
||||
LABEL org.opencontainers.image.version=${BUILD_TAG_VERSION}
|
||||
LABEL org.opencontainers.image.title=${BUILD_TAG}-${TARGETARCH}-${TARGETVARIANT}
|
||||
LABEL org.opencontainers.image.revision=${BUILD_REF}
|
||||
+18
-35
@@ -1,10 +1,10 @@
|
||||
ARG DISTRIB_ID=ubuntu
|
||||
ARG DISTRIB_RELEASE=20.04
|
||||
FROM ${DISTRIB_ID}:${DISTRIB_RELEASE}
|
||||
ARG BASEIMAGE=buildpack-deps
|
||||
ARG TAG=20.04
|
||||
FROM ${BASEIMAGE}:${TAG}
|
||||
|
||||
# > ARGs before FROM are not accessible
|
||||
ARG DISTRIB_ID=ubuntu
|
||||
ARG DISTRIB_RELEASE=20.04
|
||||
ARG BASEIMAGE=buildpack-deps
|
||||
ARG TAG=20.04
|
||||
|
||||
# > Node version
|
||||
ARG NODE_VERSION=12
|
||||
@@ -12,17 +12,17 @@ ARG NODE_VERSION=12
|
||||
# > Force apt to not be interactive/not ask
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
SHELL [ "/bin/bash", "-c" ]
|
||||
SHELL [ "/bin/bash", "--login", "-o", "pipefail", "-c" ]
|
||||
|
||||
# > setup environment required for GitHub Actions
|
||||
RUN set -Eeuxo pipefail \
|
||||
&& printf "Build started\n" \
|
||||
&& echo "USER=$(whoami)" | tee -a /etc/environment \
|
||||
&& echo "RUNNER_USER=$(whoami)" | tee -a /etc/environment \
|
||||
&& ImageOS=${DISTRIB_ID}$(echo ${DISTRIB_RELEASE} | cut -d'.' -f 1) \
|
||||
&& ImageOS=ubuntu$(echo ${TAG} | cut -d'.' -f 1) \
|
||||
&& echo "IMAGE_OS=$ImageOS" | tee -a /etc/environment \
|
||||
&& echo "ImageOS=$ImageOS" | tee -a /etc/environment \
|
||||
&& echo "LSB_RELEASE=${DISTRIB_RELEASE}" | tee -a /etc/environment \
|
||||
&& echo "LSB_RELEASE=${TAG}" | tee -a /etc/environment \
|
||||
&& AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache \
|
||||
&& echo "AGENT_TOOLSDIRECTORY=$AGENT_TOOLSDIRECTORY" | tee -a /etc/environment \
|
||||
&& echo "RUN_TOOL_CACHE=$AGENT_TOOLSDIRECTORY" | tee -a /etc/environment \
|
||||
@@ -33,44 +33,32 @@ RUN set -Eeuxo pipefail \
|
||||
&& chmod 0777 $AGENT_TOOLSDIRECTORY \
|
||||
&& mkdir -p /github \
|
||||
&& chown 1000:1000 /github \
|
||||
&& chmod 0777 /github
|
||||
|
||||
# > Install deps
|
||||
RUN set -Eeuxo pipefail \
|
||||
&& apt -yq update \
|
||||
&& chmod 0777 /github \
|
||||
&& printf "Installing packages\n\n" \
|
||||
&& apt-get -yq update \
|
||||
&& 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 xz-utils $(apt-cache search libicu | grep -E 'libicu[[:digit:]]+ -' | cut -d " " -f 1) \
|
||||
&& apt-get -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 xz-utils "$(apt-cache search libicu | grep -E 'libicu[[:digit:]]+ -' | cut -d \" \" -f 1)" \
|
||||
&& printf "Creating ~/.ssh and adding 'github.com'\n\n" \
|
||||
&& mkdir -p ~/.ssh \
|
||||
&& chmod 700 ~/.ssh \
|
||||
&& ssh-keyscan github.com | tee ~/.ssh/known_hosts \
|
||||
&& printf "Installed base utils\nInstalling docker\n" \
|
||||
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - \
|
||||
&& add-apt-repository "deb https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
|
||||
&& apt -yq update \
|
||||
&& apt -yq install docker-ce-cli \
|
||||
&& printf "Cleaning image\n" \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/cache/* \
|
||||
&& rm -rf /var/log/* \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& rm -rf /tmp/* \
|
||||
&& printf "Cleaned up image\n"
|
||||
|
||||
# > Install Node.JS
|
||||
RUN set -Eeuxo pipefail \
|
||||
&& apt-get -yq update \
|
||||
&& apt-get -yq install --no-install-recommends docker-ce-cli \
|
||||
&& printf "Installing Node.JS\n" \
|
||||
&& curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - \
|
||||
&& 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-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 install --no-install-recommends nodejs="${NODE_VERSION}*" \
|
||||
&& apt-get -yq update \
|
||||
&& apt-get -yq install --no-install-recommends nodejs="${NODE_VERSION}*" \
|
||||
&& printf "Installed Node.JS $(node -v)\n" \
|
||||
&& dpkg-query -f '${binary:Package}\n' -W \
|
||||
&& printf "Cleaning image\n" \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& rm -rf /tmp/* \
|
||||
&& rm -rf /var/cache/* /var/log/* /var/lib/apt/lists/* /tmp/* || echo 'Failed to delete directories' \
|
||||
&& printf "Cleaned up image\n"
|
||||
|
||||
ARG BUILD_TAG_VERSION="master"
|
||||
@@ -86,8 +74,3 @@ LABEL org.opencontainers.image.title=${BUILD_TAG}
|
||||
LABEL org.opencontainers.image.revision=${BUILD_REF}
|
||||
|
||||
USER root
|
||||
|
||||
SHELL [ "/bin/bash", "--login", "-c" ]
|
||||
|
||||
# > Force bash with environment
|
||||
ENTRYPOINT [ "/bin/bash", "--login", "-c" ]
|
||||
|
||||
@@ -1,99 +1,36 @@
|
||||
ARG DISTRIB_ID=ubuntu
|
||||
ARG DISTRIB_RELEASE=20.04
|
||||
FROM ${DISTRIB_ID}:${DISTRIB_RELEASE}
|
||||
ARG BASEIMAGE=catthehacker/ubuntu
|
||||
ARG TAG=act-latest
|
||||
FROM ${BASEIMAGE}:${TAG}
|
||||
|
||||
# > ARGs before FROM are not accessible
|
||||
ARG DISTRIB_ID=ubuntu
|
||||
ARG DISTRIB_RELEASE=20.04
|
||||
ARG BASEIMAGE=catthehacker/ubuntu
|
||||
ARG TAG=act-latest
|
||||
|
||||
# > non-root user
|
||||
ARG RUNNER_USER=runner
|
||||
ARG RUNNER=runner
|
||||
|
||||
# > Node version
|
||||
ARG NODE_VERSION=12
|
||||
|
||||
# > Force apt to not be interactive/not ask
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
SHELL [ "/bin/bash", "-c" ]
|
||||
|
||||
# > setup environment required for GitHub Actions
|
||||
RUN set -Eeuxo pipefail \
|
||||
&& printf "Build started\n" \
|
||||
&& ImageOS=${DISTRIB_ID}$(echo ${DISTRIB_RELEASE} | cut -d'.' -f 1) \
|
||||
&& echo "IMAGE_OS=$ImageOS" | tee -a /etc/environment \
|
||||
&& echo "ImageOS=$ImageOS" | tee -a /etc/environment \
|
||||
&& echo "LSB_RELEASE=${DISTRIB_RELEASE}" | tee -a /etc/environment \
|
||||
&& AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache \
|
||||
&& echo "AGENT_TOOLSDIRECTORY=$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 ". /etc/environment" | tee -a /etc/profile \
|
||||
&& mkdir -p $AGENT_TOOLSDIRECTORY \
|
||||
&& chown 1000:1000 $AGENT_TOOLSDIRECTORY \
|
||||
&& chmod 0777 $AGENT_TOOLSDIRECTORY \
|
||||
&& mkdir -p /github \
|
||||
&& chown 1000:1000 /github \
|
||||
&& chmod 0777 /github \
|
||||
&& echo "RUNNER_USER=${RUNNER_USER}" | tee -a /etc/environment \
|
||||
&& echo "RUNNER_TEMP=/home/${RUNNER_USER}/work/_temp" | tee -a /etc/environment
|
||||
|
||||
# > Install deps
|
||||
RUN set -Eeuxo pipefail \
|
||||
&& apt -yq update \
|
||||
&& 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 xz-utils $(apt-cache search libicu | grep -E 'libicu[[:digit:]]+ -' | cut -d " " -f 1) \
|
||||
&& printf "Installed base utils\nInstalling docker\n" \
|
||||
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - \
|
||||
&& add-apt-repository "deb https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
|
||||
&& apt -yq update \
|
||||
&& apt -yq install docker-ce-cli \
|
||||
&& printf "Cleaning image\n" \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/cache/* \
|
||||
&& rm -rf /var/log/* \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& rm -rf /tmp/* \
|
||||
&& printf "Cleaned up image\n"
|
||||
|
||||
# > Install Node.JS
|
||||
RUN set -Eeuxo pipefail \
|
||||
&& printf "Installing Node.JS\n" \
|
||||
&& curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - \
|
||||
&& 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-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 install --no-install-recommends nodejs="${NODE_VERSION}*" \
|
||||
&& printf "Installed Node.JS $(node -v)\n" \
|
||||
&& dpkg-query -f '${binary:Package}\n' -W \
|
||||
&& printf "Cleaning image\n" \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& rm -rf /tmp/* \
|
||||
&& printf "Cleaned up image\n"
|
||||
SHELL [ "/bin/bash", "--login", "-o", "pipefail", "-c" ]
|
||||
|
||||
# > Create non-root user
|
||||
RUN set -Eeuxo pipefail \
|
||||
&& printf "Creating non-root user\n" \
|
||||
&& groupadd -g 1000 ${RUNNER_USER} \
|
||||
&& useradd -u 1000 -g ${RUNNER_USER} -G sudo -m -s /bin/bash ${RUNNER_USER} \
|
||||
&& groupadd -g 1000 ${RUNNER} \
|
||||
&& useradd -u 1000 -g ${RUNNER} -G sudo -m -s /bin/bash ${RUNNER} \
|
||||
&& sed -i /etc/sudoers -re 's/^%sudo.*/%sudo ALL=(ALL:ALL) NOPASSWD: ALL/g' \
|
||||
&& sed -i /etc/sudoers -re 's/^root.*/root ALL=(ALL:ALL) NOPASSWD: ALL/g' \
|
||||
&& sed -i /etc/sudoers -re 's/^#includedir.*/## **Removed the include directive** ##"/g' \
|
||||
&& echo "${RUNNER_USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \
|
||||
&& printf "Runner user: $(su - ${RUNNER_USER} -c id)\n" \
|
||||
&& printf "Created non-root user $(grep ${RUNNER_USER} /etc/passwd)\n" \
|
||||
&& echo "USER=${RUNNER_USER}" | tee -a /etc/environment \
|
||||
&& echo "RUNNER_USER=${RUNNER_USER}" | tee -a /etc/environment \
|
||||
&& echo "RUNNER_TEMP=/home/${RUNNER_USER}/work/_temp" | tee -a /etc/environment \
|
||||
&& mkdir -p "/home/${RUNNER_USER}/work/_temp" \
|
||||
&& chown -R ${RUNNER_USER}:${RUNNER_USER} "/home/${RUNNER_USER}/work" \
|
||||
&& mkdir -p "/home/${RUNNER_USER}/.ssh" \
|
||||
&& chmod 700 "/home/${RUNNER_USER}/.ssh" \
|
||||
&& ssh-keyscan github.com | tee "/home/${RUNNER_USER}/.ssh/known_hosts" \
|
||||
&& chmod 644 "/home/${RUNNER_USER}/.ssh/known_hosts" \
|
||||
&& chown -R ${RUNNER_USER}:${RUNNER_USER} "/home/${RUNNER_USER}/.ssh"
|
||||
&& echo "${RUNNER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \
|
||||
&& printf "Runner user: $(su - ${RUNNER} -c id)\n" \
|
||||
&& printf "Created non-root user $(grep ${RUNNER} /etc/passwd)\n" \
|
||||
&& sed -i /etc/environment -e "s/USER=root/USER=${RUNNER}/g" \
|
||||
&& echo "RUNNER_TEMP=/home/${RUNNER}/work/_temp" | tee -a /etc/environment \
|
||||
&& mkdir -p "/home/${RUNNER}/work/_temp" \
|
||||
&& chown -R ${RUNNER}:${RUNNER} "/home/${RUNNER}/work" \
|
||||
&& mkdir -p "/home/${RUNNER}/.ssh" \
|
||||
&& chmod 700 "/home/${RUNNER}/.ssh" \
|
||||
&& ssh-keyscan github.com | tee "/home/${RUNNER}/.ssh/known_hosts" \
|
||||
&& chmod 644 "/home/${RUNNER}/.ssh/known_hosts" \
|
||||
&& chown -R ${RUNNER}:${RUNNER} "/home/${RUNNER}/.ssh"
|
||||
|
||||
ARG BUILD_TAG_VERSION="master"
|
||||
ARG BUILD_TAG="runner"
|
||||
@@ -101,19 +38,12 @@ ARG BUILD_REF="master"
|
||||
|
||||
LABEL org.opencontainers.image.vendor="catthehacker"
|
||||
LABEL org.opencontainers.image.authors="me@hackerc.at"
|
||||
LABEL org.opencontainers.image.url="https://github.com/catthehacker/docker_images"
|
||||
LABEL org.opencontainers.image.url="https://github.com/catthehacker/docker_images/linux/${BASEIMAGE}/${IMAGE_TYPE}"
|
||||
LABEL org.opencontainers.image.source="https://github.com/catthehacker/docker_images.git"
|
||||
LABEL org.opencontainers.image.version=${BUILD_TAG_VERSION}
|
||||
LABEL org.opencontainers.image.title=${BUILD_TAG}
|
||||
LABEL org.opencontainers.image.revision=${BUILD_REF}
|
||||
|
||||
|
||||
# > Don't run as root, generally not good idea
|
||||
USER ${RUNNER_USER}:${RUNNER_USER}
|
||||
USER ${RUNNER}
|
||||
|
||||
WORKDIR /home/runner
|
||||
|
||||
SHELL [ "/bin/bash", "--login", "-c" ]
|
||||
|
||||
# > Force bash with environment
|
||||
ENTRYPOINT [ "/bin/bash", "--login", "-c" ]
|
||||
|
||||
Reference in New Issue
Block a user