mirror of
https://github.com/ChristianLight/tutor.git
synced 2024-12-12 14:17:46 +00:00
Pull vendor images from the command line
Vendor docker image versions are no longer hardcoded in environment files.
This commit is contained in:
parent
b84b0a6eed
commit
6a746eada0
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
## Latest
|
## Latest
|
||||||
|
|
||||||
|
- [Improvement] `images pull` now also pulls vendor images
|
||||||
- [Feature] Add convenient `config printvalue` command
|
- [Feature] Add convenient `config printvalue` command
|
||||||
- [Feature] Customize docker registry
|
- [Feature] Customize docker registry
|
||||||
- [Feature] Load configuration parameters from the system environment
|
- [Feature] Load configuration parameters from the system environment
|
||||||
|
@ -10,9 +10,13 @@ from . import utils
|
|||||||
def images():
|
def images():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
all_images = ["openedx", "forum", "notes", "xqueue", "android"]
|
OPENEDX_IMAGES = ["openedx", "forum", "notes", "xqueue", "android"]
|
||||||
|
VENDOR_IMAGES = ["elasticsearch", "memcached", "mongodb", "mysql", "namshi", "nginx", "rabbitmq"]
|
||||||
|
argument_openedx_image = click.argument(
|
||||||
|
"image", type=click.Choice(["all"] + OPENEDX_IMAGES),
|
||||||
|
)
|
||||||
argument_image = click.argument(
|
argument_image = click.argument(
|
||||||
"image", type=click.Choice(["all"] + all_images),
|
"image", type=click.Choice(["all"] + OPENEDX_IMAGES + VENDOR_IMAGES),
|
||||||
)
|
)
|
||||||
|
|
||||||
@click.command(
|
@click.command(
|
||||||
@ -20,14 +24,14 @@ argument_image = click.argument(
|
|||||||
help="Build the docker images necessary for an Open edX platform."
|
help="Build the docker images necessary for an Open edX platform."
|
||||||
)
|
)
|
||||||
@opts.root
|
@opts.root
|
||||||
@argument_image
|
@argument_openedx_image
|
||||||
@click.option(
|
@click.option(
|
||||||
"-a", "--build-arg", multiple=True,
|
"-a", "--build-arg", multiple=True,
|
||||||
help="Set build-time docker ARGS in the form 'myarg=value'. This option may be specified multiple times."
|
help="Set build-time docker ARGS in the form 'myarg=value'. This option may be specified multiple times."
|
||||||
)
|
)
|
||||||
def build(root, image, build_arg):
|
def build(root, image, build_arg):
|
||||||
config = tutor_config.load(root)
|
config = tutor_config.load(root)
|
||||||
for image in image_list(config, image):
|
for image in openedx_image_names(config, image):
|
||||||
tag = get_tag(config, image)
|
tag = get_tag(config, image)
|
||||||
click.echo(fmt.info("Building image {}".format(tag)))
|
click.echo(fmt.info("Building image {}".format(tag)))
|
||||||
command = [
|
command = [
|
||||||
@ -40,22 +44,22 @@ def build(root, image, build_arg):
|
|||||||
]
|
]
|
||||||
utils.docker(*command)
|
utils.docker(*command)
|
||||||
|
|
||||||
@click.command(short_help="Pull images from the docker registry")
|
@click.command(short_help="Pull images from the Docker registry")
|
||||||
@opts.root
|
@opts.root
|
||||||
@argument_image
|
@argument_image
|
||||||
def pull(root, image):
|
def pull(root, image):
|
||||||
config = tutor_config.load(root)
|
config = tutor_config.load(root)
|
||||||
for image in image_list(config, image):
|
for image in image_names(config, image):
|
||||||
tag = get_tag(config, image)
|
tag = get_tag(config, image)
|
||||||
click.echo(fmt.info("Pulling image {}".format(tag)))
|
click.echo(fmt.info("Pulling image {}".format(tag)))
|
||||||
utils.execute("docker", "pull", tag)
|
utils.execute("docker", "pull", tag)
|
||||||
|
|
||||||
@click.command(short_help="Push images to the Docker registry")
|
@click.command(short_help="Push images to the Docker registry")
|
||||||
@opts.root
|
@opts.root
|
||||||
@argument_image
|
@argument_openedx_image
|
||||||
def push(root, image):
|
def push(root, image):
|
||||||
config = tutor_config.load(root)
|
config = tutor_config.load(root)
|
||||||
for image in image_list(config, image):
|
for image in openedx_image_names(config, image):
|
||||||
tag = get_tag(config, image)
|
tag = get_tag(config, image)
|
||||||
click.echo(fmt.info("Pushing image {}".format(tag)))
|
click.echo(fmt.info("Pushing image {}".format(tag)))
|
||||||
utils.execute("docker", "push", tag)
|
utils.execute("docker", "push", tag)
|
||||||
@ -67,9 +71,12 @@ def get_tag(config, name):
|
|||||||
image=image,
|
image=image,
|
||||||
)
|
)
|
||||||
|
|
||||||
def image_list(config, image):
|
def image_names(config, image):
|
||||||
|
return openedx_image_names(config, image) + vendor_image_names(config, image)
|
||||||
|
|
||||||
|
def openedx_image_names(config, image):
|
||||||
if image == "all":
|
if image == "all":
|
||||||
images = all_images[:]
|
images = OPENEDX_IMAGES[:]
|
||||||
if not config['ACTIVATE_XQUEUE']:
|
if not config['ACTIVATE_XQUEUE']:
|
||||||
images.remove('xqueue')
|
images.remove('xqueue')
|
||||||
if not config['ACTIVATE_NOTES']:
|
if not config['ACTIVATE_NOTES']:
|
||||||
@ -77,6 +84,9 @@ def image_list(config, image):
|
|||||||
return images
|
return images
|
||||||
return [image]
|
return [image]
|
||||||
|
|
||||||
|
def vendor_image_names(config, image):
|
||||||
|
return VENDOR_IMAGES if image == "all" else image
|
||||||
|
|
||||||
images.add_command(build)
|
images.add_command(build)
|
||||||
images.add_command(pull)
|
images.add_command(pull)
|
||||||
images.add_command(push)
|
images.add_command(push)
|
||||||
|
@ -4,6 +4,13 @@ DOCKER_IMAGE_ANDROID: "regis/openedx-android:hawthorn"
|
|||||||
DOCKER_IMAGE_FORUM: "regis/openedx-forum:hawthorn"
|
DOCKER_IMAGE_FORUM: "regis/openedx-forum:hawthorn"
|
||||||
DOCKER_IMAGE_NOTES: "regis/openedx-notes:hawthorn"
|
DOCKER_IMAGE_NOTES: "regis/openedx-notes:hawthorn"
|
||||||
DOCKER_IMAGE_XQUEUE: "regis/openedx-xqueue:hawthorn"
|
DOCKER_IMAGE_XQUEUE: "regis/openedx-xqueue:hawthorn"
|
||||||
|
DOCKER_IMAGE_MEMCACHED: "memcached:1.4.38"
|
||||||
|
DOCKER_IMAGE_MONGODB: "mongo:3.2.16"
|
||||||
|
DOCKER_IMAGE_MYSQL: "mysql:5.6.36"
|
||||||
|
DOCKER_IMAGE_ELASTICSEARCH: "elasticsearch:1.5.2"
|
||||||
|
DOCKER_IMAGE_NGINX: "nginx:1.13"
|
||||||
|
DOCKER_IMAGE_RABBITMQ: "rabbitmq:3.6.10"
|
||||||
|
DOCKER_IMAGE_NAMSHI: "namshi/smtp:latest"
|
||||||
DOCKER_REGISTRY: ""
|
DOCKER_REGISTRY: ""
|
||||||
MYSQL_DATABASE: "openedx"
|
MYSQL_DATABASE: "openedx"
|
||||||
MYSQL_USERNAME: "openedx"
|
MYSQL_USERNAME: "openedx"
|
||||||
|
@ -128,7 +128,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: elasticsearch
|
- name: elasticsearch
|
||||||
image: {{ DOCKER_REGISTRY }}elasticsearch:1.5.2
|
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_ELASTICSEARCH }}
|
||||||
env:
|
env:
|
||||||
- name: ES_JAVA_OPTS
|
- name: ES_JAVA_OPTS
|
||||||
value: "-Xms1g -Xmx1g"
|
value: "-Xms1g -Xmx1g"
|
||||||
@ -163,7 +163,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: memcached
|
- name: memcached
|
||||||
image: {{ DOCKER_REGISTRY }}memcached:1.4.38
|
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_MEMCACHED }}
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 11211
|
- containerPort: 11211
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: mongodb
|
- name: mongodb
|
||||||
image: {{ DOCKER_REGISTRY }}mongo:3.2.16
|
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_MONGODB }}
|
||||||
command: ["mongod", "--smallfiles", "--nojournal", "--storageEngine", "wiredTiger"]
|
command: ["mongod", "--smallfiles", "--nojournal", "--storageEngine", "wiredTiger"]
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 27017
|
- containerPort: 27017
|
||||||
@ -212,7 +212,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: mysql
|
- name: mysql
|
||||||
image: {{ DOCKER_REGISTRY }}mysql:5.6.36
|
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_MYSQL }}
|
||||||
env:
|
env:
|
||||||
- name: MYSQL_ROOT_PASSWORD
|
- name: MYSQL_ROOT_PASSWORD
|
||||||
valueFrom:
|
valueFrom:
|
||||||
@ -261,7 +261,7 @@ spec:
|
|||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
containers:
|
containers:
|
||||||
- name: nginx
|
- name: nginx
|
||||||
image: {{ DOCKER_REGISTRY }}nginx:1.13
|
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_NGINX }}
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- mountPath: /etc/nginx/conf.d/
|
- mountPath: /etc/nginx/conf.d/
|
||||||
name: config
|
name: config
|
||||||
@ -302,7 +302,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: rabbitmq
|
- name: rabbitmq
|
||||||
image: {{ DOCKER_REGISTRY }}rabbitmq:3.6.10
|
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_RABBITMQ }}
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 5672
|
- containerPort: 5672
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
|
@ -4,11 +4,11 @@ services:
|
|||||||
############# External services
|
############# External services
|
||||||
|
|
||||||
memcached:
|
memcached:
|
||||||
image: {{ DOCKER_REGISTRY }}memcached:1.4.38
|
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_MEMCACHED }}
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
mongodb:
|
mongodb:
|
||||||
image: {{ DOCKER_REGISTRY }}mongo:3.2.16
|
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_MONGODB }}
|
||||||
# Use WiredTiger in all environments, just like at edx.org
|
# Use WiredTiger in all environments, just like at edx.org
|
||||||
command: mongod --smallfiles --nojournal --storageEngine wiredTiger
|
command: mongod --smallfiles --nojournal --storageEngine wiredTiger
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
@ -16,7 +16,7 @@ services:
|
|||||||
- ../../data/mongodb:/data/db
|
- ../../data/mongodb:/data/db
|
||||||
|
|
||||||
mysql:
|
mysql:
|
||||||
image: {{ DOCKER_REGISTRY }}mysql:5.6.36
|
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_MYSQL }}
|
||||||
command: mysqld --character-set-server=utf8 --collation-server=utf8_general_ci
|
command: mysqld --character-set-server=utf8 --collation-server=utf8_general_ci
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
volumes:
|
volumes:
|
||||||
@ -24,7 +24,7 @@ services:
|
|||||||
env_file: ../apps/mysql/auth.env
|
env_file: ../apps/mysql/auth.env
|
||||||
|
|
||||||
elasticsearch:
|
elasticsearch:
|
||||||
image: {{ DOCKER_REGISTRY }}elasticsearch:1.5.2
|
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_ELASTICSEARCH }}
|
||||||
environment:
|
environment:
|
||||||
- "ES_JAVA_OPTS=-Xms1g -Xmx1g"
|
- "ES_JAVA_OPTS=-Xms1g -Xmx1g"
|
||||||
- "cluster.name=openedx"
|
- "cluster.name=openedx"
|
||||||
@ -44,7 +44,7 @@ services:
|
|||||||
command: bash -c "rm -rf /var/www/openedx/staticfiles && cp -r /openedx/staticfiles/ /var/www/openedx/"
|
command: bash -c "rm -rf /var/www/openedx/staticfiles && cp -r /openedx/staticfiles/ /var/www/openedx/"
|
||||||
|
|
||||||
nginx:
|
nginx:
|
||||||
image: {{ DOCKER_REGISTRY }}nginx:1.13
|
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_NGINX }}
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "{{ NGINX_HTTP_PORT }}:80"
|
- "{{ NGINX_HTTP_PORT }}:80"
|
||||||
@ -61,14 +61,14 @@ services:
|
|||||||
{% if ACTIVATE_NOTES %}- notes{% endif %}
|
{% if ACTIVATE_NOTES %}- notes{% endif %}
|
||||||
|
|
||||||
rabbitmq:
|
rabbitmq:
|
||||||
image: {{ DOCKER_REGISTRY }}rabbitmq:3.6.10
|
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_RABBITMQ }}
|
||||||
volumes:
|
volumes:
|
||||||
- ../../data/rabbitmq:/var/lib/rabbitmq
|
- ../../data/rabbitmq:/var/lib/rabbitmq
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
# Simple SMTP server
|
# Simple SMTP server
|
||||||
smtp:
|
smtp:
|
||||||
image: {{ DOCKER_REGISTRY }}namshi/smtp:latest
|
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_NAMSHI }}
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
############# Forum
|
############# Forum
|
||||||
|
Loading…
Reference in New Issue
Block a user