fix: add RUNNER ARG

This commit is contained in:
hackercat
2021-05-18 20:59:44 +00:00
parent 377301fa5e
commit 3e763ddfb6
+15 -14
View File
@@ -4,26 +4,27 @@ FROM ${BASEIMAGE}:${TAG}
SHELL [ "/bin/ash", "-o", "pipefail", "-l", "-c" ] SHELL [ "/bin/ash", "-o", "pipefail", "-l", "-c" ]
ARG RUNNER=runner
# > Create non-root user # > Create non-root user
RUN set -euxo pipefail \ RUN set -euxo pipefail \
&& printf "Creating non-root user\n" \ && 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 \ && addgroup -S ${RUNNER} -g 1000 && adduser -S ${RUNNER} -u 1000 -G ${RUNNER} -s /usr/bin/fish \
&& sed -i /etc/sudoers -re 's/^%sudo.*/%sudo ALL=(ALL:ALL) NOPASSWD: ALL/g' \ && 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/^root.*/root ALL=(ALL:ALL) NOPASSWD: ALL/g' \
&& sed -i /etc/sudoers -re 's/^#includedir.*/## **Removed the include directive** ##"/g' \ && sed -i /etc/sudoers -re 's/^#includedir.*/## **Removed the include directive** ##"/g' \
&& echo "${RUNNER_USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \ && echo "${RUNNER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \
&& printf "Runner user: $(su - ${RUNNER_USER} -c id)\n" \ && printf "Runner user: $(su - ${RUNNER} -c id)\n" \
&& printf "Created non-root user $(grep ${RUNNER_USER} /etc/passwd)\n" \ && printf "Created non-root user $(grep ${RUNNER} /etc/passwd)\n" \
&& echo "USER=${RUNNER_USER}" | tee -a /etc/environment \ && sed -i /etc/environment -e "s/USER=root/USER=${RUNNER}/g" \
&& echo "RUNNER_USER=${RUNNER_USER}" | tee -a /etc/environment \ && echo "RUNNER_TEMP=/home/${RUNNER}/work/_temp" | tee -a /etc/environment \
&& echo "RUNNER_TEMP=/home/${RUNNER_USER}/work/_temp" | tee -a /etc/environment \ && mkdir -p "/home/${RUNNER}/work/_temp" \
&& mkdir -p "/home/${RUNNER_USER}/work/_temp" \ && chown -R ${RUNNER}:${RUNNER} "/home/${RUNNER}/work" \
&& chown -R ${RUNNER_USER}:${RUNNER_USER} "/home/${RUNNER_USER}/work" \ && mkdir -p "/home/${RUNNER}/.ssh" \
&& mkdir -p "/home/${RUNNER_USER}/.ssh" \ && chmod 700 "/home/${RUNNER}/.ssh" \
&& chmod 700 "/home/${RUNNER_USER}/.ssh" \ && ssh-keyscan github.com | tee "/home/${RUNNER}/.ssh/known_hosts" \
&& ssh-keyscan github.com | tee "/home/${RUNNER_USER}/.ssh/known_hosts" \ && chmod 644 "/home/${RUNNER}/.ssh/known_hosts" \
&& chmod 644 "/home/${RUNNER_USER}/.ssh/known_hosts" \ && chown -R ${RUNNER}:${RUNNER} "/home/${RUNNER}/.ssh"
&& chown -R ${RUNNER_USER}:${RUNNER_USER} "/home/${RUNNER_USER}/.ssh"
ARG BUILD_TAG_VERSION="master" ARG BUILD_TAG_VERSION="master"
ARG BUILD_TAG="runner" ARG BUILD_TAG="runner"