Skip to content
Snippets Groups Projects
Commit 6d7455d3 authored by Pierre Ozoux's avatar Pierre Ozoux
Browse files

A universal starter for docker compose

parent 1146fbf4
No related branches found
No related tags found
No related merge requests found
[Unit]
Description=Back up data from %i
[Service]
Type=oneshot
TimeoutStartSec=0
WorkingDirectory=/data/domains/%i/
EnvironmentFile=/etc/environment
ExecStartPre=/bin/bash -euxc ' \
/bin/docker run \
--rm \
--name clean-%i \
-e PASSPHRASE \
-v /root:/root \
indiepaas/duplicity \
remove-older-than 10D --force \
sftp://${BACKUP_DESTINATION}/%i'
ExecStartPre=/bin/bash -euxc '/data/domains/%i/BACKUP'
ExecStart=/bin/bash -euxc ' \
/bin/docker run \
--rm \
--name backup-%i \
-e PASSPHRASE \
-h backup.container \
--cpu-shares=40 \
-v /root:/root \
-v /data/domains/%i:/backup indiepaas/duplicity \
--full-if-older-than 1W \
--encrypt-key ${ENCRYPT_KEY} \
/backup \
sftp://${BACKUP_DESTINATION}/%i'
[Unit]
Description=Hourly backup of www and mysql content.
# Dependency binding
BindsTo=u@%i.service
[Timer]
OnActiveSec=20
OnUnitActiveSec=60min
AccuracySec=50min
[Unit]
Description=%p for %i etcd registration
# Requirements
Requires=etcd.service
# Dependency binding
BindsTo=u@%i.service
[Service]
Type=oneshot
RemainAfterExit=yes
Environment=URL=%i
ExecStart=/bin/bash -xc ' \
ip=""; \
while [ -z $ip ]; \
do \
container_name=`echo ${URL}_web_1 | sed "s/\.//g" | sed "s/-//g"`; \
ip=`docker inspect --format \'{{.NetworkSettings.IPAddress}}\' $container_name`; \
sleep 1; \
done; \
etcdctl --peers 172.17.42.1:4001 set /services/web/%i \'{"ip":"\'$ip\'", "port":"80"}\';'
ExecStop=-/usr/bin/etcdctl rm /services/web/%i
[Unit]
Description=%p-%i
# Requirements
Requires=docker.service
Requires=d-u@%i.service
Requires=b-u@%i.timer
# Dependency ordering
After=docker.service
Before=d-u@%i.service
Before=b-u@%i.timer
[Service]
Restart=always
RestartSec=10
TimeoutStartSec=60
TimeoutStopSec=15
WorkingDirectory=/data/domains/%i/
ExecStartPre=/bin/cp /data/domains/%i/TLS/%i.pem /data/runtime/haproxy/approved-certs/%i.pem
ExecStartPre=-/opt/bin/docker-compose rm -f
ExecStart=/opt/bin/docker-compose up
ExecStop=/opt/bin/docker-compose stop
[Install]
WantedBy=multi-user.target
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment