Skip to content

Commit

Permalink
Merge pull request #127 from mikedep333/support-pulp-3.0rc2-and-night…
Browse files Browse the repository at this point in the history
…ly-git

containers: Update to support Pulp 3.0 rc2
  • Loading branch information
bmbouter authored May 10, 2019
2 parents f0bd807 + 2f6d75c commit 0d520a9
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 12 deletions.
6 changes: 4 additions & 2 deletions containers/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Pulp 3 Containers

This directory contains assets and tooling for building Pulp 3 container images. The current image is an all-in-one image with different runtime scripts to assume each of the roles: pulp-core, pulp-worker and pulp-resource-manager.
This directory contains assets and tooling for building Pulp 3 container images. The current image is an all-in-one image with different runtime scripts to assume each of the roles: pulp-api, pulp-content, pulp-worker and pulp-resource-manager.

## Build

Expand All @@ -10,7 +10,9 @@ The base image can be built with the help of an Ansible script. To build the bas

The image can be customized to include any number of plugins as a build argument:

ansible-playbook build.yaml -e '{"plugins": ["pulp_file", "pulp_ansible"]}'
ansible-playbook build.yaml -e '{"plugins": ["pulp_file", "pulp_ansible", "pulp_cookbook", "pulp_docker", "pulp_maven", "pulp_python"]}'

ansible-playbook build.yaml -e '{"plugins": ["git+https://github.com/pulp/pulp_file.git", "git+https://github.com/pulp/pulp_ansible.git", "git+https://github.com/gmbnomis/pulp_cookbook.git", "git+https://github.com/pulp/pulp_docker.git", "git+https://github.com/pulp/pulp_maven.git", "git+https://github.com/pulp/pulp_python.git"]}'

## Push Image to Registry

Expand Down
24 changes: 20 additions & 4 deletions containers/images/pulp-api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ FROM centos:7

ARG PLUGINS=""

# mariadb_devel needed to avoid error installing pulpcore[mysql] (post-rc1)
# otherwise, `mysql_config` is not found
# It also needs gcc at least, so we install the dev tools package group.
# And it needs Python.h
RUN echo "tsflags=nodocs" >> /etc/yum.conf && \
yum -y update && \
yum -y install epel-release centos-release-scl && \
yum -y install wget git rh-python36-python-pip && \
yum -y install @development mariadb-devel rh-python36-python-devel && \
yum clean all

ENV LANG=en_US.UTF-8
Expand All @@ -16,15 +22,25 @@ ENV DJANGO_SETTINGS_MODULE=pulpcore.app.settings
RUN mkdir -p /etc/pulp

RUN scl enable rh-python36 'pip install gunicorn'
RUN scl enable rh-python36 'pip install pulpcore'
RUN scl enable rh-python36 'pip install pulpcore-plugin pulpcore[postgres] pulpcore[mysql]'
RUN scl enable rh-python36 'pip install git+https://github.com/pulp/pulpcore.git'
RUN scl enable rh-python36 'pip install git+https://github.com/pulp/pulpcore-plugin.git'
RUN scl enable rh-python36 'pip install git+https://github.com/pulp/pulpcore.git#egg=pulpcore[postgres]'
RUN scl enable rh-python36 'pip install git+https://github.com/pulp/pulpcore.git#egg=pulpcore[mysql]'
RUN scl enable rh-python36 'pip install $PLUGINS'

RUN scl enable rh-python36 "django-admin collectstatic --noinput"
RUN mkdir -p /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pulpcore/app/migrations
RUN mkdir -p /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pulpcore/app/migrations
RUN mkdir -p /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pulp_file/app/migrations
RUN mkdir -p /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pulp_ansible/app/migrations
RUN mkdir -p /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pulp_cookbook/app/migrations
RUN mkdir -p /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pulp_docker/app/migrations
RUN mkdir -p /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pulp_maven/app/migrations
RUN mkdir -p /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pulp_python/app/migrations

COPY container-assets/wait_on_postgres.py /usr/bin/wait_on_postgres.py
COPY container-assets/wait_on_database_migrations.sh /usr/bin/wait_on_database_migrations.sh
COPY container-assets/pulp-common-entrypoint.sh /pulp-common-entrypoint.sh
COPY container-assets/pulp-api /usr/bin/pulp-api


ENTRYPOINT ["/pulp-common-entrypoint.sh"]
CMD ["/usr/bin/pulp-api"]
15 changes: 13 additions & 2 deletions containers/images/pulp-api/container-assets/pulp-api
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

/usr/bin/wait_on_postgres.py

scl enable rh-python36 'django-admin migrate --noinput'
# Generating /var/lib/pulp/static at runtime rather than at container build time
# facilitates all of /var/lib/pulp being a separate volume.
scl enable rh-python36 "django-admin collectstatic --noinput"

exec scl enable rh-python36 "gunicorn -b 0.0.0.0:8000 pulpcore.app.wsgi:application"
#TODO: Determine list of installed plugins by inspecting image contents
scl enable rh-python36 "django-admin makemigrations file ansible cookbook docker maven python"
scl enable rh-python36 "django-admin migrate --noinput"
scl enable rh-python36 "django-admin migrate auth --noinput"

if [ -n "${PULP_ADMIN_PASSWORD}" ]; then
scl enable rh-python36 "django-admin reset-admin-password --password '${PULP_ADMIN_PASSWORD}'"
fi

exec scl enable rh-python36 "gunicorn -b 0.0.0.0:24817 pulpcore.app.wsgi:application"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

export DJANGO_SETTINGS_MODULE=pulpcore.app.settings

exec "$@"
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ database_migrated=false

echo "Checking for database migrations"
while [ $database_migrated = false ]; do
scl enable rh-python36 "pulp-manager showmigrations | grep '\[ \]'"
scl enable rh-python36 "django-admin showmigrations | grep '\[ \]'"
if [ $? -gt 0 ]; then
echo "Database migrated!"
database_migrated=true
Expand Down
6 changes: 5 additions & 1 deletion containers/images/pulp-content/container-assets/pulp-content
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
/usr/bin/wait_on_postgres.py
/usr/bin/wait_on_database_migrations.sh

exec scl enable rh-python36 "gunicorn -b 0.0.0.0:8000 pulpcore.content:server"
exec scl enable rh-python36 "gunicorn pulpcore.content:server \
--bind 0.0.0.0:24816 \
--worker-class 'aiohttp.GunicornWebWorker' \
-w 2 \
--access-logfile -"
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
/usr/bin/wait_on_postgres.py
/usr/bin/wait_on_database_migrations.sh

exec scl enable rh-python36 "rq worker --url 'redis://$REDIS_SERVICE_HOST:$REDIS_SERVICE_PORT' -n resource_manager@%h -w 'pulpcore.tasking.worker.PulpWorker'"
exec scl enable rh-python36 "rq worker --url 'redis://$REDIS_SERVICE_HOST:$REDIS_SERVICE_PORT' -n resource-manager@%h -w 'pulpcore.tasking.worker.PulpWorker' -c 'pulpcore.rqconfig'"
4 changes: 3 additions & 1 deletion containers/images/pulp-worker/container-assets/pulp-worker
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
/usr/bin/wait_on_postgres.py
/usr/bin/wait_on_database_migrations.sh

exec scl enable rh-python36 "rq worker --url 'redis://${REDIS_SERVICE_HOST}:${REDIS_SERVICE_PORT}' -n reserved_resource_worker_${PULP_WORKER_NUMBER}@${HOSTNAME} -w 'pulpcore.tasking.worker.PulpWorker'"
# TODO: Set ${PULP_WORKER_NUMBER} to the Pod Number
# In the meantime, the hostname provides uniqueness.
exec scl enable rh-python36 "rq worker --url 'redis://${REDIS_SERVICE_HOST}:${REDIS_SERVICE_PORT}' -n reserved-resource-worker-${PULP_WORKER_NUMBER}@${HOSTNAME} -w 'pulpcore.tasking.worker.PulpWorker' -c 'pulpcore.rqconfig'"

0 comments on commit 0d520a9

Please sign in to comment.