From 0fcc672ac3c14cea1a749c4b36ab8de6b0851042 Mon Sep 17 00:00:00 2001 From: Baptiste Bouchereau Date: Mon, 4 Mar 2019 23:11:48 +1300 Subject: [PATCH] Clone the playbooks during the build rather than during container initialization --- Dockerfile | 7 ++++++- entrypoint.sh | 7 ------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 850a472..b1c8ad4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,9 @@ FROM ovski/ansible:v2.7.8 +# Clone ansible playbooks +RUN git clone https://gitlab.com/ovski-projects/infra/ansible-playbooks/borg-backup.git /var/borg-backup-playbook +RUN git clone https://gitlab.com/ovski-projects/infra/ansible-playbooks/mysql-dump.git /var/mysql-dump-playbook + # Install borg RUN apt-get install -y \ python3 \ @@ -13,7 +17,7 @@ RUN apt-get install -y \ # Install packages for mysqldump RUN apt-get install -y mysql-client -RUN pip install PyMySql +RUN pip3 install PyMySql # Install cron RUN apt-get install -y cron @@ -25,6 +29,7 @@ COPY borgbackup_cron /etc/cron.d/borgbackup_cron RUN chmod +x /etc/cron.d/borgbackup_cron RUN crontab /etc/cron.d/borgbackup_cron +# Setup entrypoint COPY entrypoint.sh /var/entrypoint.sh RUN chmod +x /var/entrypoint.sh ENTRYPOINT [ "/var/entrypoint.sh" ] diff --git a/entrypoint.sh b/entrypoint.sh index c63310a..f96397c 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,7 +2,6 @@ set -eo pipefail shopt -s nullglob -# Add known hosts if [[ -n "$SSH_KNOWN_HOSTS" ]]; then echo "Adding domains and ips to known hosts" mkdir -p ~/.ssh @@ -15,12 +14,6 @@ if [[ -n "$SSH_KNOWN_HOSTS" ]]; then done <<< "$SSH_KNOWN_HOSTS" fi -# Clone ansible playbooks -echo "Cloning ansible gitlab repositories" -git clone https://gitlab.com/ovski-projects/infra/ansible-playbooks/borg-backup.git /var/borg-backup-playbook -git clone https://gitlab.com/ovski-projects/infra/ansible-playbooks/mysql-dump.git /var/mysql-dump-playbook - -# Set borg passphrase env variable if [[ -f /run/secrets/borg_passphrase ]]; then echo "Setting BORG_PASSPHRASE env variable from secret" export BORG_PASSPHRASE=$(cat /run/secrets/borg_passphrase)