Commit 6a2a9506 authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

split between public and private registries

parent b18de578
ARG REGISTRY=eur0c.laas.fr:4567
ARG NAMESPACE=gsaurel/buildfarm
ARG REGISTRY=eur0c.laas.fr:5000
ARG NAMESPACE=buildfarm
ARG IMAGE=robotpkg
ARG TARGET=14.04
......
......@@ -158,4 +158,5 @@ LOGGING = {
RAINBOARD_DATA = Path('/srv/dashboard')
RAINBOARD_GITS = RAINBOARD_DATA / 'repositories'
RAINBOARD_RPKG = RAINBOARD_DATA / 'robotpkg'
REGISTRY = 'eur0c.laas.fr:4567'
PRIVATE_REGISTRY = 'eur0c.laas.fr:4567'
PUBLIC_REGISTRY = 'eur0c.laas.fr:5000'
......@@ -12,13 +12,9 @@ class Command(BaseCommand):
help = 'Create all docker images'
def handle(self, *args, **options):
logger.info('Creating all docker images…')
for robotpkg in Robotpkg.objects.all():
logger.info(f' {robotpkg}')
robotpkg.update_images()
logger.info('Building all docker images…')
for image in Image.objects.all():
ret = call(image.build())
logger.info(f' {image}: {ret}')
if ret == 0:
image.update()
......@@ -279,6 +279,9 @@ class Project(Links, NamedModel, TimeStampedModel):
contributor.save()
return self.contributor_set.all()
def registry(self):
return settings.PUBLIC_REGISTRY if self.public else settings.PRIVATE_REGISTRY
class Repo(TimeStampedModel):
name = models.CharField(max_length=200)
......@@ -594,14 +597,15 @@ class Image(models.Model):
return f'{self.robotpkg}-{self.get_target_display()}'
def get_build_args(self):
ret = {'TARGET': self.get_target_display(), 'ROBOTPKG': self.robotpkg}
ret = {'TARGET': self.get_target_display(), 'ROBOTPKG': self.robotpkg,
'REGISTRY': self.robotpkg.project.registry}
if not self.robotpkg.project.public:
ret['IMAGE'] = 'robotpkg-jrl'
return ret
def get_image_name(self):
project = self.robotpkg.project
return f'{settings.REGISTRY}/{project.main_namespace.slug}/{project}:{self.get_target_display()}'
return f'{project.registry}/{project.main_namespace.slug}/{project}:{self.get_target_display()}'
def build(self):
args = self.get_build_args()
......
......@@ -4,7 +4,8 @@ variables:
GIT_DEPTH: "3"
NAMESPACE: {{ project.main_namespace.slug }}
PROJECT: {{ project }}
IMAGE: "${CI_REGISTRY}/${NAMESPACE}/${PROJECT}"
REGISTRY: {{ project.registry }}
IMAGE: "${REGISTRY}/${NAMESPACE}/${PROJECT}"
cache:
paths:
......
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