Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade s6-overlay from v2 to v3 #78

Merged
merged 4 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"[shellscript]": {
"editor.defaultFormatter": "foxundermoon.shell-format",
"editor.formatOnSave": true,
}
},
"docker.languageserver.formatter.ignoreMultilineInstructions": true
}
17 changes: 11 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,14 @@ ENV AGENT_WORKDIR="${HOME}/agent" \
## Entrypoint related \
# Fails if cont-init and fix-attrs fails \
S6_BEHAVIOUR_IF_STAGE2_FAILS=2 \
# Wait for dind before running CMD \
S6_CMD_WAIT_FOR_SERVICES=1
# Wait for services before running CMD \
S6_CMD_WAIT_FOR_SERVICES=1 \
# Give 15s for services to start \
S6_CMD_WAIT_FOR_SERVICES_MAXTIME=15000 \
# Give 15s for services to stop \
S6_SERVICES_GRACETIME=15000 \
# Honor container env on CMD \
S6_KEEP_ENV=1

# create non-root user
RUN group="${NON_ROOT_USER}"; \
Expand Down Expand Up @@ -248,10 +254,9 @@ RUN \
# install helm 3 \
${CURL} https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | sudo -E bash -; \
# install s6-overlay \
${CURL} -o /tmp/s6-overlay-installer https://github.com/just-containers/s6-overlay/releases/download/v2.2.0.1/s6-overlay-amd64-installer; \
chmod +x /tmp/s6-overlay-installer; \
sudo /tmp/s6-overlay-installer /; \
rm -f /tmp/s6-overlay-installer; \
version="3.1.6.2"; \
${CURL} https://github.com/just-containers/s6-overlay/releases/download/v${version}/s6-overlay-noarch.tar.xz | sudo tar -C / -Jxpf -; \
${CURL} https://github.com/just-containers/s6-overlay/releases/download/v${version}/s6-overlay-x86_64.tar.xz | sudo tar -C / -Jxpf -; \
# fix sshd not starting \
sudo mkdir -p /run/sshd; \
# install fixuid \
Expand Down
2 changes: 2 additions & 0 deletions init_as_root.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

set -eu

# This can probably be improved:
# https://github.com/just-containers/s6-overlay/issues/394#issuecomment-1690769622
if [[ "${SSHD_ENABLED:-false}" == true ]]; then
mv -f /etc/optional-services.d/sshd /etc/services.d/sshd
fi
Expand Down
3 changes: 3 additions & 0 deletions rootfs/etc/optional-services.d/sshd/check_readiness.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

exec ssh -q -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null [email protected] true &>/dev/null
7 changes: 2 additions & 5 deletions rootfs/etc/optional-services.d/sshd/run
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash
#!/bin/bash

set -eu

echo "[sshd] starting service" >&2
exec s6-notifyoncheck -c \
"ssh -q -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null jenkins@localhost true" \
/usr/sbin/sshd -D -e
exec s6-notifyoncheck -c /etc/services.d/sshd/check_readiness.sh /usr/sbin/sshd -D -e
3 changes: 3 additions & 0 deletions rootfs/etc/services.d/dind/check_readiness.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

exec docker version &>/dev/null
5 changes: 2 additions & 3 deletions rootfs/etc/services.d/dind/run
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash
#!/bin/bash

set -eu

echo "[dind] starting service" >&2
exec s6-notifyoncheck -c "docker version" dind dockerd
exec s6-notifyoncheck -c /etc/services.d/dind/check_readiness.sh dind dockerd