Commit 2e61daa9 authored by Chris Lamb's avatar Chris Lamb 💬

Pull (create/update) the docker image.

parent a745e701
Pipeline #48428 passed with stages
in 2 minutes and 30 seconds
......@@ -88,6 +88,16 @@
src: "celery.service"
dest: "/etc/systemd/system/celery.service"
- name: pull image
become: true
become_user: www-data
shell:
"{{ base_dir }}/{{ project_name }}/manage.py pull_image"
register: pull_image_output
- debug:
var: pull_image_output.stdout_lines
- name: start/restart gunicorn
systemd:
name: "gunicorn"
......
from django.core.management.base import BaseCommand
from ...utils import pull_image
class Command(BaseCommand):
def handle(self, *args, **options):
pull_image()
import celery
from .utils import clean_images, clean_containers
from . import utils
@celery.task()
def cleanup():
clean_images()
clean_containers()
utils.clean_images()
utils.clean_containers()
@celery.task()
def pull_image():
utils.pull_image()
......@@ -75,3 +75,7 @@ def clean_containers():
),
shell=True,
)
def pull_image():
subprocess.call(('docker', 'pull', app_settings.DOCKER_IMAGE))
......@@ -96,6 +96,10 @@ CELERYBEAT_SCHEDULE = {
'task': 'trydiffoscope.compare.retention_policy.tasks.purge',
'schedule': crontab(minute=0),
},
'pull-image': {
'task': 'trydiffoscope.container.tasks.pull_image',
'schedule': crontab(hour=0, minute=0),
},
}
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment