I have a setup on a Pi for deploying progscrape.com that has a systemd task to boot a new runner in a container. I really need to turn it into a bare-metal deployment script so I can recover from an SD card crash.
Basically this service:
[Unit]
Description=%N Container
After=docker.service
Requires=docker.service
[Service]
TimeoutSec=3600
Restart=always
WorkingDirectory=/srv/progscrape/progscrape-deploy/github-runners
ExecStartPre=-/usr/bin/docker compose -f %N.yml -p %N stop
ExecStartPre=-/usr/bin/docker compose -f %N.yml -p %N pull
ExecStart=/usr/bin/docker compose -f %N.yml -p %N up
ExecStopPost=-/usr/bin/docker compose -f %N.yml -p %N rm -f
[Install]
WantedBy=multi-user.target
Boots this docker compose definition: services:
github-docker-runner:
image: myoung34/github-runner:latest
restart: "no"
environment:
RUNNER_NAME: progscrape-docker-compose
RUNNER_WORKDIR: /tmp/work
EPHEMERAL: 1
LABELS: management,linux,ARM64
DISABLE_AUTO_UPDATE: 1
env_file:
- github-runner.env
configs:
- github-runner-start
entrypoint: /bin/sh
command: /github-runner-start
security_opt:
# needed on SELinux systems to allow docker container to manage other docker containers
- label:disable
volumes:
- '/var/run/docker.sock:/var/run/docker.sock'
configs:
github-runner-start:
file: runner-start.sh