Commit 7834fa76 authored by Michał "rysiek" Woźniak's avatar Michał "rysiek" Woźniak
Browse files

entrypoint: now auto-registering when no config

parent 1b9965cf
......@@ -95,4 +95,8 @@ RUN if [ "$INSTALL_PACKAGES" != "" ]; then \
RUN gem2.4 install jekyll:'<4' bundler:'<2'
RUN /usr/bin/npm install bower -g
# copy in the entrypoint script
COPY entrypoint /
RUN chmod +x /entrypoint
VOLUME ["/etc/gitlab-runner", "/home/gitlab-runner", "/output"]
#!/bin/bash
#
# almost exact copy of:
# https://gitlab.com/gitlab-org/gitlab-runner/blob/master/dockerfiles/ubuntu/entrypoint
# (original is MIT-licensed)
#
# we need our copy because we want to run gitlab-runner as a specific user:group
#
# gitlab-runner data directory
DATA_DIR="/etc/gitlab-runner"
CONFIG_FILE=${CONFIG_FILE:-$DATA_DIR/config.toml}
# custom certificate authority path
CA_CERTIFICATES_PATH=${CA_CERTIFICATES_PATH:-$DATA_DIR/certs/ca.crt}
LOCAL_CA_PATH="/usr/local/share/ca-certificates/ca.crt"
update_ca() {
echo "Updating CA certificates..."
cp "${CA_CERTIFICATES_PATH}" "${LOCAL_CA_PATH}"
update-ca-certificates --fresh >/dev/null
}
if [ -f "${CA_CERTIFICATES_PATH}" ]; then
# update the ca if the custom ca is different than the current
cmp --silent "${CA_CERTIFICATES_PATH}" "${LOCAL_CA_PATH}" || update_ca
fi
# if we don't have a config file...
if [[ ! -e ${CONFIG_FILE} ]]; then
echo "+-- no config file found in: '${CONFIG_FILE}'"
# ...but we do have config vars...
if [[ -n ${CI_SERVER_URL} && -n ${RUNNER_TOKEN} && -n ${RUNNER_DESCRIPTION} && -n ${RUNNER_EXECUTOR} ]]; then
echo " configuration vars found, registering a new runner..."
# register the runner
su gitlab-runner -c \
"gitlab-runner register --non-interactive --config '${CONFIG_FILE}' --url '${CI_SERVER_URL}' --registration-token '${RUNNER_TOKEN}' --description '${RUNNER_DESCRIPTION}' --executor '${RUNNER_EXECUTOR}'"
else
echo " ERROR: no config file and no configuration vars!"
exit 1
fi
fi
# launch gitlab-runner passing all arguments
exec gitlab-runner "$@"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment