Modified to use bootstrap archive.

This commit is contained in:
yohan 2020-02-22 19:53:58 +01:00
parent 55250f2b55
commit 687832542c
2 changed files with 49 additions and 19 deletions

View File

@ -4,7 +4,7 @@ services:
reverse-proxy: reverse-proxy:
image: reverse-proxy:$VERSION_PROXY image: reverse-proxy:$VERSION_PROXY
build: "https://git.scimetis.net/yohan/docker-reverse-proxy.git" #build: "https://git.scimetis.net/yohan/docker-reverse-proxy.git"
restart: always restart: always
ports: ports:
- 80:80/tcp - 80:80/tcp
@ -12,13 +12,13 @@ services:
networks: networks:
- reverse-proxy - reverse-proxy
volumes: volumes:
- reverse-proxy_conf:/etc/apache2/sites-available:Z - /mnt/volumes/reverse-proxy_conf/data:/etc/apache2/sites-available:Z
- reverse-proxy_conf_enabled:/etc/apache2/sites-enabled:Z - /mnt/volumes/reverse-proxy_conf_enabled/data:/etc/apache2/sites-enabled:Z
- reverse-proxy_letsencrypt:/etc/letsencrypt:Z - /mnt/volumes/reverse-proxy_letsencrypt/data:/etc/letsencrypt:Z
cron: cron:
image: cron:$VERSION_CRON image: cron:$VERSION_CRON
build: "https://git.scimetis.net/yohan/docker-cron.git" #build: "https://git.scimetis.net/yohan/docker-cron.git"
restart: always restart: always
network_mode: "host" network_mode: "host"
volumes: volumes:
@ -28,14 +28,3 @@ networks:
reverse-proxy: reverse-proxy:
external: true external: true
volumes:
reverse-proxy_conf:
external: true
reverse-proxy_conf_enabled:
external: true
reverse-proxy_letsencrypt:
external: true

View File

@ -1,9 +1,50 @@
#!/bin/bash #!/bin/bash
test -f ~/openrc.sh || exit 1
source ~/openrc.sh
INSTANCE=$(~/env_py3/bin/openstack server show -c id --format value $(hostname))
for VOLUME in reverse-proxy_conf reverse-proxy_conf_enabled reverse-proxy_letsencrypt
do
if ! mountpoint -q /mnt/volumes/${VOLUME}
then
VOLUME_ID=$(/home/yohan/env_py3/bin/openstack volume show ${VOLUME} -c id --format value)
test -e /dev/disk/by-id/*${VOLUME_ID:0:20} || nova volume-attach $INSTANCE $VOLUME_ID auto
sudo mount /dev/disk/by-id/*${VOLUME_ID:0:20} /mnt/volumes/${VOLUME}
fi
done
sudo chown root. crontab sudo chown root. crontab
sudo chmod 644 crontab sudo chmod 644 crontab
export OS_REGION_NAME=GRA
source ~/duplicity_password.sh
sudo docker image inspect duplicity:latest &> /dev/null ||{ echo "ERROR: duplicity:latest image not found, exiting."; exit 1; }
rm -rf ~/build
mkdir -p ~/build
for name in docker-cron docker-reverse-proxy
do
sudo -E docker run --rm -e SWIFT_USERNAME=$OS_USERNAME \
-e SWIFT_PASSWORD=$OS_PASSWORD \
-e SWIFT_AUTHURL=$OS_AUTH_URL \
-e SWIFT_AUTHVERSION=$OS_IDENTITY_API_VERSION \
-e SWIFT_TENANTNAME=$OS_TENANT_NAME \
-e SWIFT_REGIONNAME=$OS_REGION_NAME \
-e PASSPHRASE=$PASSPHRASE \
--name backup-restore -v ~/build:/mnt/build --entrypoint /bin/bash duplicity:latest \
-c "duplicity restore --name bootstrap --file-to-restore ${name}.tar.gz swift://bootstrap /mnt/build/${name}.tar.gz"
tar -xzf ~/build/${name}.tar.gz -C ~/build/
done
# --force-recreate is used to recreate container when crontab file has changed # --force-recreate is used to recreate container when crontab file has changed
unset VERSION_PROXY VERSION_CRON unset VERSION_PROXY VERSION_CRON
VERSION_PROXY=$(git ls-remote https://git.scimetis.net/yohan/docker-reverse-proxy.git| head -1 | cut -f 1|cut -c -10) \ DIRECTORY=$(pwd)
VERSION_CRON=$(git ls-remote https://git.scimetis.net/yohan/docker-cron.git| head -1 | cut -f 1|cut -c -10) \ cd ~/build/docker-reverse-proxy; export VERSION_PROXY=$(git show-ref --head| head -1 | cut -f 1|cut -c -10); cd $DIRECTORY
sudo -E bash -c 'docker-compose up -d --force-recreate' cd ~/build/docker-cron; export VERSION_CRON=$(git show-ref --head| head -1 | cut -f 1|cut -c -10); cd $DIRECTORY
sudo docker build -t reverse-proxy:$VERSION_PROXY ~/build/docker-reverse-proxy
sudo docker build -t cron:$VERSION_CRON ~/build/docker-cron
sudo -E bash -c 'docker-compose up -d --force-recreate'
rm -rf ~/build