Loading .gitlab-ci.yml +0 −43 Original line number Diff line number Diff line Loading @@ -4,7 +4,6 @@ image: adarnimrod/ci-images:docker stages: - test - build - run pre-commit: stage: test Loading Loading @@ -44,45 +43,3 @@ build-ns4: - ns4.shore.co.il variables: *build_vars script: *build_script run-host01: stage: run tags: - host01.shore.co.il variables: RUNNER_NAME: host01.shore.co.il RUNNER_TAG_LIST: host01.shore.co.il REGISTER_RUN_UNTAGGED: "false" when: manual script: &run-script - docker-compose up --detach --remove-orphans # yamllint disable rule:line-length - | for i in $(seq 12) do docker container inspect --format '{{ .State.Health.Status }}' $(docker-compose ps -q) | grep -v '^healthy$' || break sleep 10 done ! docker container inspect --format '{{ .State.Health.Status }}' $(docker-compose ps -q) | grep -v '^healthy$' run-kodi: stage: run tags: - kodi.shore.co.il variables: RUNNER_NAME: kodi.shore.co.il RUNNER_TAG_LIST: kodi.shore.co.il REGISTER_RUN_UNTAGGED: "false" when: manual script: *run-script run-ns4: stage: run tags: - ns4.shore.co.il variables: RUNNER_NAME: ns4.shore.co.il RUNNER_TAG_LIST: ns4.shore.co.il REGISTER_RUN_UNTAGGED: "true" when: manual script: *run-script .pre-commit-config.yaml +5 −0 Original line number Diff line number Diff line Loading @@ -27,3 +27,8 @@ repos: hooks: - id: docker-compose - id: hadolint - repo: https://git.shore.co.il/nimrod/shell-pre-commit.git sha: v0.6.0 hooks: - id: shell-lint - id: shellcheck README.md +5 −3 Original line number Diff line number Diff line Loading @@ -11,10 +11,12 @@ dockerd socket mounted inside the container). ## Usage First, get the registration token from https://git.shore.co.il/admin/runners. To build and run on `ns4.shore.co.il`, just run: The CI will pull and build images, all that's left to do is recreate the containers. But the jobs fail is the runner is recreated during the job. The workaround is the `deploy` script. ``` DOCKER_HOST=ssh://ns4.shore.co.il docker-compose build && DOCKER_HOST=ssh://ns4.shore.co.il REGISTRATION_TOKEN='INSERT_TOKEN' RUNNER_NAME=ns4.shore.co.il REGISTER_RUN_UNTAGGED="true" docker-compose up -d REGISTRATION_TOKEN='INSERT_TOKEN' ./deploy ``` ## License Loading deploy 0 → 100755 +32 −0 Original line number Diff line number Diff line #!/bin/sh set -eu deploy() { echo "Deploying to $1" >&2 export DOCKER_HOST="ssh://$1" export RUNNER_NAME="$1" until docker-compose up --detach --remove-orphans 2>/dev/null; do true; done # shellcheck disable=SC2034 for i in $(seq 12) do # shellcheck disable=SC2046 docker container inspect --format '{{ .State.Health.Status }}' $(docker-compose ps -q) | grep -v '^healthy$' || break sleep 10 done # shellcheck disable=SC2046 ! docker container inspect --format '{{ .State.Health.Status }}' $(docker-compose ps -q) | grep -v '^healthy$' unset DOCKER_HOST unset RUNNER_NAME } if [ -z "${REGISTRATION_TOKEN:-}" ] then echo "REGISTRATION_TOKEN isn't set." >&2 exit 1 fi export REGISTER_RUN_UNTAGGED="false" deploy "host01.shore.co.il" deploy "kodi.shore.co.il" export REGISTER_RUN_UNTAGGED="true" deploy "ns4.shore.co.il" Loading
.gitlab-ci.yml +0 −43 Original line number Diff line number Diff line Loading @@ -4,7 +4,6 @@ image: adarnimrod/ci-images:docker stages: - test - build - run pre-commit: stage: test Loading Loading @@ -44,45 +43,3 @@ build-ns4: - ns4.shore.co.il variables: *build_vars script: *build_script run-host01: stage: run tags: - host01.shore.co.il variables: RUNNER_NAME: host01.shore.co.il RUNNER_TAG_LIST: host01.shore.co.il REGISTER_RUN_UNTAGGED: "false" when: manual script: &run-script - docker-compose up --detach --remove-orphans # yamllint disable rule:line-length - | for i in $(seq 12) do docker container inspect --format '{{ .State.Health.Status }}' $(docker-compose ps -q) | grep -v '^healthy$' || break sleep 10 done ! docker container inspect --format '{{ .State.Health.Status }}' $(docker-compose ps -q) | grep -v '^healthy$' run-kodi: stage: run tags: - kodi.shore.co.il variables: RUNNER_NAME: kodi.shore.co.il RUNNER_TAG_LIST: kodi.shore.co.il REGISTER_RUN_UNTAGGED: "false" when: manual script: *run-script run-ns4: stage: run tags: - ns4.shore.co.il variables: RUNNER_NAME: ns4.shore.co.il RUNNER_TAG_LIST: ns4.shore.co.il REGISTER_RUN_UNTAGGED: "true" when: manual script: *run-script
.pre-commit-config.yaml +5 −0 Original line number Diff line number Diff line Loading @@ -27,3 +27,8 @@ repos: hooks: - id: docker-compose - id: hadolint - repo: https://git.shore.co.il/nimrod/shell-pre-commit.git sha: v0.6.0 hooks: - id: shell-lint - id: shellcheck
README.md +5 −3 Original line number Diff line number Diff line Loading @@ -11,10 +11,12 @@ dockerd socket mounted inside the container). ## Usage First, get the registration token from https://git.shore.co.il/admin/runners. To build and run on `ns4.shore.co.il`, just run: The CI will pull and build images, all that's left to do is recreate the containers. But the jobs fail is the runner is recreated during the job. The workaround is the `deploy` script. ``` DOCKER_HOST=ssh://ns4.shore.co.il docker-compose build && DOCKER_HOST=ssh://ns4.shore.co.il REGISTRATION_TOKEN='INSERT_TOKEN' RUNNER_NAME=ns4.shore.co.il REGISTER_RUN_UNTAGGED="true" docker-compose up -d REGISTRATION_TOKEN='INSERT_TOKEN' ./deploy ``` ## License Loading
deploy 0 → 100755 +32 −0 Original line number Diff line number Diff line #!/bin/sh set -eu deploy() { echo "Deploying to $1" >&2 export DOCKER_HOST="ssh://$1" export RUNNER_NAME="$1" until docker-compose up --detach --remove-orphans 2>/dev/null; do true; done # shellcheck disable=SC2034 for i in $(seq 12) do # shellcheck disable=SC2046 docker container inspect --format '{{ .State.Health.Status }}' $(docker-compose ps -q) | grep -v '^healthy$' || break sleep 10 done # shellcheck disable=SC2046 ! docker container inspect --format '{{ .State.Health.Status }}' $(docker-compose ps -q) | grep -v '^healthy$' unset DOCKER_HOST unset RUNNER_NAME } if [ -z "${REGISTRATION_TOKEN:-}" ] then echo "REGISTRATION_TOKEN isn't set." >&2 exit 1 fi export REGISTER_RUN_UNTAGGED="false" deploy "host01.shore.co.il" deploy "kodi.shore.co.il" export REGISTER_RUN_UNTAGGED="true" deploy "ns4.shore.co.il"