Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev: Move cmds from helper container to a extended Dockerfile #2309

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,6 @@ db_snapshots/
# this is convenient to save history between container runs
# but we don't want it on the repo
.bash_history

# Shell plus from container run saves a session
.ipython
24 changes: 24 additions & 0 deletions dev/compose/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This Dockerfile is meant to extend the main Dockerfile.rhel8
# Moving files to the required places
# Installing extra development libraries and tools
FROM localhost/galaxy_ng/galaxy_ng:base

ARG GNUPGHOME
ENV GNUPGHOME $GNUPGHOME

USER root

RUN /app/dev/compose/signing/setup_gpg_workarounds.sh

RUN set -ex; \
install -Dm 0775 /app/dev/compose/database/database_fields.symmetric.key /etc/pulp/certs/database_fields.symmetric.key && \
install -Dm 0775 /app/dev/compose/signing/signing-secret.key /etc/pulp/certs/signing-secret.key && \
install -Dm 0775 /app/dev/compose/signing/signing-secret.key.password.txt /etc/pulp/certs/signing-secret.key.password.txt && \
install -Dm 0775 /app/dev/compose/signing/signing-secret.key /etc/pulp/certs/signing-public.key && \
install -Dm 0775 /app/dev/compose/signing/collection_sign.sh /var/lib/pulp/scripts/collection_sign.sh && \
install -Dm 0775 /app/dev/compose/signing/container_sign.sh /var/lib/pulp/scripts/container_sign.sh && \
chmod +x /var/lib/pulp/scripts/*_sign.sh

RUN /app/dev/compose/signing/setup_gpg_keys.sh

RUN ${VIRTUAL_ENV}/bin/python3 -m pip install ipython ipdb django-extensions
86 changes: 21 additions & 65 deletions dev/compose/aap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ services:
dockerfile: Dockerfile
image: "localhost/galaxy_ng/galaxy_ng:base"

base_img_dev: # Extends base_img with extra files and dev tools
depends_on:
- base_img
build:
context: .
dockerfile: Dockerfile.dev
args:
<<: *common-env
image: "localhost/galaxy_ng/galaxy_ng:dev"

redis:
image: "redis:5"

Expand All @@ -104,48 +114,11 @@ services:
# WARNING: enabling log_statement=all makes database slower
# command: ["postgres", "-c", "log_statement=ddl", "-c", "log_destination=stderr"]

helper: # should this be moved to a custom Dockerfile based on base_img?
image: quay.io/centos/centos:stream9
environment:
<<: *common-env
depends_on:
- postgres
volumes:
- "etc_pulp_certs:/etc/pulp/certs"
- "var_lib_pulp:/var/lib/pulp"
- "../../../:/src"
- "../../:/app"
command: |
bash -c "
echo 'Moving required files to the required places.';

# Workarounds - Pulp SigningService can't access envvars;
/src/galaxy_ng/dev/compose/signing/setup_gpg_workarounds.sh;
cat /etc/pulp/certs/GNUPGHOME.workaround.txt;
cat /etc/pulp/certs/HOME.workaround.txt;

# Keys;
cp /src/galaxy_ng/dev/compose/database/database_fields.symmetric.key /etc/pulp/certs/database_fields.symmetric.key;
cp /src/galaxy_ng/dev/compose/signing/signing-secret.key /etc/pulp/certs/signing-secret.key;
cp /src/galaxy_ng/dev/compose/signing/signing-secret.key.password.txt /etc/pulp/certs/signing-secret.key.password.txt;
cp /src/galaxy_ng/dev/compose/signing/signing-secret.key /etc/pulp/certs/signing-public.key;
find /etc/pulp/certs;

# Scripts;
cp /src/galaxy_ng/dev/compose/signing/collection_sign.sh /var/lib/pulp/scripts/collection_sign.sh;
cp /src/galaxy_ng/dev/compose/signing/container_sign.sh /var/lib/pulp/scripts/container_sign.sh;
chmod +x /var/lib/pulp/scripts/*_sign.sh;
find /var/lib/pulp/scripts;

echo 'DONE!';
"

migrations:
image: "localhost/galaxy_ng/galaxy_ng:base"
image: "localhost/galaxy_ng/galaxy_ng:dev"
depends_on:
- base_img
- base_img_dev
- postgres
- helper
volumes:
- "etc_pulp_certs:/etc/pulp/certs"
- "var_lib_pulp:/var/lib/pulp"
Expand All @@ -158,8 +131,6 @@ services:
bash -c "
set -e;
rm -rf /var/lib/pulp/.migrated;

/src/galaxy_ng/dev/compose/bin/wait /etc/pulp/certs/database_fields.symmetric.key;
/src/galaxy_ng/dev/compose/bin/devinstall;

pulpcore-manager check --database default;
Expand All @@ -171,11 +142,10 @@ services:
"

api:
image: "localhost/galaxy_ng/galaxy_ng:base"
image: "localhost/galaxy_ng/galaxy_ng:dev"
depends_on:
- base_img
- base_img_dev
- postgres
- helper
- migrations
volumes:
- "etc_pulp_certs:/etc/pulp/certs"
Expand All @@ -199,11 +169,10 @@ services:
"

content:
image: "localhost/galaxy_ng/galaxy_ng:base"
image: "localhost/galaxy_ng/galaxy_ng:dev"
depends_on:
- base_img
- base_img_dev
- postgres
- helper
- migrations
volumes:
- "etc_pulp_certs:/etc/pulp/certs"
Expand All @@ -227,11 +196,10 @@ services:
"

worker:
image: "localhost/galaxy_ng/galaxy_ng:base"
image: "localhost/galaxy_ng/galaxy_ng:dev"
depends_on:
- base_img
- base_img_dev
- postgres
- helper
- migrations
volumes:
- "etc_pulp_certs:/etc/pulp/certs"
Expand All @@ -244,22 +212,19 @@ services:
command: |
bash -c "
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;
/src/galaxy_ng/dev/compose/bin/wait /etc/pulp/certs/signing-secret.key;
/src/galaxy_ng/dev/compose/bin/devinstall;

# Worker needs gpg in order to consume signing tasks;
/src/galaxy_ng/dev/compose/signing/setup_gpg_keys.sh;
gpg --list-secret-keys;

/src/galaxy_ng/dev/compose/bin/reloader /venv/bin/pulpcore-worker
"

manager:
image: "localhost/galaxy_ng/galaxy_ng:base"
image: "localhost/galaxy_ng/galaxy_ng:dev"
depends_on:
- base_img
- base_img_dev
- postgres
- helper
- migrations
- worker
volumes:
Expand All @@ -273,7 +238,6 @@ services:
command: |
bash -c "
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;
/src/galaxy_ng/dev/compose/bin/wait /etc/pulp/certs/signing-secret.key;
/src/galaxy_ng/dev/compose/bin/devinstall;

# Give some time for API to start;
Expand All @@ -284,21 +248,15 @@ services:
echo 'Scheduled tasks';
curl -s -u $$DJANGO_SUPERUSER_USERNAME:$$DJANGO_SUPERUSER_PASSWORD http://api:24817/api/galaxy/pulp/api/v3/task-schedules/?name=dab_sync | python -m json.tool;

# Keys are needed to register signing services;
/src/galaxy_ng/dev/compose/signing/setup_gpg_keys.sh;
gpg --list-secret-keys;

# Setup signing services;
gpg --list-secret-keys;
/src/galaxy_ng/dev/compose/signing/setup_signing_services.sh;
echo 'Signing Services';
curl -s -u $$DJANGO_SUPERUSER_USERNAME:$$DJANGO_SUPERUSER_PASSWORD http://api:24817/api/galaxy/pulp/api/v3/signing-services/?fields=name,script,pubkey_fingerprint | python -m json.tool;

# Setup repository gpgkey for upload verification;
/src/galaxy_ng/dev/compose/signing/setup_repo_keyring.sh;

# Dev tools; SHOULD THIS MOVE TO A CUSTOM Dockerfile?;
/venv/bin/pip3.11 install ipython ipdb django-extensions;

echo ' ';
echo '###################### API ROOT ##############################';
curl -s http://api:24817/api/galaxy/ | python -m json.tool;
Expand All @@ -321,9 +279,7 @@ services:
nginx:
image: "nginx:latest"
depends_on:
- base_img
- postgres
- helper
- migrations
- api
- content
Expand Down
Loading