Compare commits

...

2 Commits

2 changed files with 75 additions and 0 deletions

66
init.d/dc Normal file
View File

@ -0,0 +1,66 @@
#!/sbin/openrc-run
# From https://github.com/0x17de/dockerservice-openrc
: ${SUBCFGDIR:=/srv/docker}
DOCKER_COMPOSE_UP_ARGS=${DOCKER_COMPOSE_UP_ARGS-"--no-build --no-recreate --no-deps"}
SUBSVC="${SVCNAME#*.}"
[ -z "${SUBSVC}" ] && exit 1
: ${SUBCFG:="${SUBCFGDIR}/${SUBSVC}/docker-compose.yml"}
DOCOCMD="/usr/bin/docker"
export COMPOSE_HTTP_TIMEOUT=300
description="Manage Docker services defined in ${SUBCFG}"
extra_commands="configtest build"
description_configtest="Check configuration via \"docker compose -f ${SUBCFG} config\""
description_build="Run \"docker compose -f ${SUBCFG} build\""
depend() {
need localmount net docker
use dns
after docker
}
configtest() {
if ! [ -f "${SUBCFG}" ]; then
eerror "The config file ${SUBCFG} does not exist!"
return 1
fi
"${DOCOCMD}" -f "${SUBCFG}" config >&/dev/null
if [ ${?} -ne 0 ]; then
einfo "config: ok"
else
eerror "config: error"
return 1
fi
}
build() {
configtest || return 1
ebegin "Building dockerservice ${SUBSVC}"
"${DOCOCMD}" compose -f "${SUBCFG}" build
eend $?
}
start() {
configtest || return 1
ebegin "Starting dockerservice ${SUBSVC}"
"${DOCOCMD}" compose -f "${SUBCFG}" up -d ${DOCKER_COMPOSE_UP_ARGS}
eend $?
}
stop() {
ebegin "Stopping dockerservice ${SUBSVC}"
"${DOCOCMD}" compose -f "${SUBCFG}" stop --timeout=300
eend $?
}
status() {
if [ "$("${DOCOCMD}" compose -f "${SUBCFG}" top | wc -l)" -gt "0" ]; then
einfo "status: started"
else
einfo "status: stopped"
return 3
fi
}

View File

@ -0,0 +1,9 @@
version: "3.9"
services:
jslave:
env_file:
- /etc/jslave/jslave.conf
image: "reg.cadoles.com/cadoles/jenkins-slave:latest"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /srv/jenkins/workspace:/workspace