ci(Dockerfile): Add cron and adapted configuration for automated backups

New package (cron) for internal scheduling and edit docker entrypoint to start the daemon accordingly. Backups scheduled every Saturday at 4:00.
This commit is contained in:
Tanguy Herbron 2022-10-22 21:57:29 +02:00
parent 2b15da0b34
commit 1d96cafe06

View File

@ -23,7 +23,9 @@ build-image:
- echo "RELEASE_PACKAGE=gitlab-ce" >> RELEASE - echo "RELEASE_PACKAGE=gitlab-ce" >> RELEASE
- echo "RELEASE_VERSION=$GITLAB_SHORT_VER-ce" >> RELEASE - echo "RELEASE_VERSION=$GITLAB_SHORT_VER-ce" >> RELEASE
- echo "DOWNLOAD_URL=http://random.com" >> RELEASE - echo "DOWNLOAD_URL=http://random.com" >> RELEASE
- sed -i '14 i \ libatomic1 \\' Dockerfile - sed -i '14 i \ libatomic1 cron \\' Dockerfile
- sed -i '45 i \ \n\# Setup crontab for scheduled backups\nRUN { cat; echo \"0 5 * * 6 gitlab-backup create SKIP=registry,builds,artifacts\"; } | crontab -\n\n' Dockerfile
- sed '/gitlab-ctl reconfigure/a \\nif command -v cron\; then\n\techo \"Starting cron daemon...\"\n\tcron\nfi' assets/wrapper > assets/wrapper
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t $CI_REGISTRY/athens-school/gitlab:$GITLAB_SHORT_VER . - docker build -t $CI_REGISTRY/athens-school/gitlab:$GITLAB_SHORT_VER .
- docker push $CI_REGISTRY/athens-school/gitlab:$GITLAB_SHORT_VER - docker push $CI_REGISTRY/athens-school/gitlab:$GITLAB_SHORT_VER