Skip to content

Commit aec6a84

Browse files
authored
Use galaxy user instead of root (#2449)
Signed-off-by: Fabricio Aguiar <[email protected]> rh-pre-commit.version: 2.3.2 rh-pre-commit.check-secrets: ENABLED
1 parent 414a532 commit aec6a84

15 files changed

+131
-47
lines changed

.github/workflows/ci-docker-compose-integration.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
4848
- name: Spin up dev/compose/${{ matrix.env.TEST_PROFILE }}.yaml
4949
run: |
50-
docker compose -f dev/compose/${{ matrix.env.TEST_PROFILE }}.yaml up --detach
50+
USER_ID=$(id --user) docker compose -f dev/compose/${{ matrix.env.TEST_PROFILE }}.yaml up --detach
5151
5252
- name: Export environment variables to host
5353
if: ${{ matrix.env.TEST_PROFILE != 'certified-sync' }}

.github/workflows/ci_automation_hub_collection.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
7373
- name: Spin up dev/compose/standalone.yaml
7474
run: |
75-
docker compose -f dev/compose/standalone.yaml up --detach
75+
USER_ID=$(id --user) docker compose -f dev/compose/standalone.yaml up --detach
7676
7777
- name: Export environment variables to host
7878
run: |

Dockerfile.rhel8

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
FROM registry.access.redhat.com/ubi8
22

33
ARG GIT_COMMIT
4+
ARG USER_ID=1000
45

56
ENV LANG=en_US.UTF-8 \
67
PYTHONUNBUFFERED=1 \
@@ -11,7 +12,7 @@ ENV LANG=en_US.UTF-8 \
1112
GIT_COMMIT=${GIT_COMMIT:-} \
1213
VIRTUAL_ENV="/venv"
1314

14-
RUN adduser --uid 1000 --gid 0 --home-dir /app --no-create-home galaxy
15+
RUN adduser --uid "${USER_ID}" -G 0 --home-dir /app --no-create-home galaxy
1516

1617
# https://access.redhat.com/security/cve/CVE-2021-3872
1718
RUN rpm -qa | egrep ^vim | xargs rpm -e --nodeps
@@ -46,19 +47,19 @@ RUN chgrp -R 0 $HOME && \
4647
RUN set -ex; \
4748
install -dm 0775 -o galaxy \
4849
/var/lib/pulp/{artifact,assets,media,scripts,tmp} \
49-
/etc/pulp/{certs,keys} \
50+
/etc/pulp/{certs,keys,gnupg} \
5051
/tmp/ansible && \
5152
pip3.11 install --no-deps --editable /app && \
5253
PULP_CONTENT_ORIGIN=x django-admin collectstatic && \
53-
install -Dm 0644 /app/ansible.cfg /etc/ansible/ansible.cfg && \
54-
install -Dm 0644 /app/docker/etc/settings.py /etc/pulp/settings.py && \
55-
install -Dm 0755 /app/docker/entrypoint.sh /entrypoint.sh && \
56-
install -Dm 0755 /app/docker/bin/* /usr/local/bin/ && \
57-
install -Dm 0775 /app/galaxy-operator/bin/* /usr/bin/
54+
install -Dm 0644 -o galaxy /app/ansible.cfg /etc/ansible/ansible.cfg && \
55+
install -Dm 0644 -o galaxy /app/docker/etc/settings.py /etc/pulp/settings.py && \
56+
install -Dm 0755 -o galaxy /app/docker/entrypoint.sh /entrypoint.sh && \
57+
install -Dm 0755 -o galaxy /app/docker/bin/* /usr/local/bin/ && \
58+
install -Dm 0775 -o galaxy /app/galaxy-operator/bin/* /usr/bin/
5859

5960
USER galaxy
6061
WORKDIR /app
61-
VOLUME [ "/var/lib/pulp/artifact", \
62-
"/var/lib/pulp/tmp", \
62+
VOLUME [ "/var/lib/pulp", \
63+
"/etc/pulp", \
6364
"/tmp/ansible" ]
6465
ENTRYPOINT [ "/entrypoint.sh" ]

Makefile

+63-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
.SILENT:
22

3+
# set the USER_ID to the current user uid
4+
export USER_ID = $(shell id --user)
5+
36
.DEFAULT:
47
.PHONY: help
58
help: ## Show the help.
@@ -173,11 +176,12 @@ test/unit: ## Run unit tests
173176
tox -e py311
174177

175178
.PHONY: test/integration/standalone
176-
test/integration/standalone: ## Run integration tests
179+
test/integration/standalone: ## Run standalone integration tests
177180
# if pytest is not found raise a warning and install it
178181
@which pytest || (echo "pytest not found, installing it now" && pip install -r integration_requirements.txt)
179-
@echo "Running integration tests"
180-
HUB_ADMIN_PASS=admin \
182+
@echo "Running standalone integration tests"
183+
HUB_LOCAL=1 \
184+
HUB_USE_MOVE_ENDPOINT="true" \
181185
HUB_API_ROOT=http://localhost:5001/api/galaxy/ \
182186
GALAXYKIT_SLEEP_SECONDS_POLLING=.5 \
183187
GALAXYKIT_SLEEP_SECONDS_ONETIME=.5 \
@@ -188,3 +192,59 @@ test/integration/standalone: ## Run integration tests
188192
pytest galaxy_ng/tests/integration \
189193
-p 'no:pulpcore' -p 'no:pulp_ansible' \
190194
-v -r sx --color=yes -m 'deployment_standalone or all'
195+
196+
.PHONY: test/integration/community
197+
test/integration/community: ## Run community integration tests
198+
# if pytest is not found raise a warning and install it
199+
@which pytest || (echo "pytest not found, installing it now" && pip install -r integration_requirements.txt)
200+
@echo "Running community integration tests"
201+
HUB_LOCAL=1 \
202+
HUB_TEST_AUTHENTICATION_BACKEND=community \
203+
HUB_API_ROOT=http://localhost:5001/api/ \
204+
GALAXYKIT_SLEEP_SECONDS_POLLING=.5 \
205+
GALAXYKIT_SLEEP_SECONDS_ONETIME=.5 \
206+
GALAXYKIT_POLLING_MAX_ATTEMPTS=50 \
207+
GALAXY_SLEEP_SECONDS_POLLING=.5 \
208+
GALAXY_SLEEP_SECONDS_ONETIME=.5 \
209+
GALAXY_POLLING_MAX_ATTEMPTS=50 \
210+
pytest galaxy_ng/tests/integration \
211+
-p 'no:pulpcore' -p 'no:pulp_ansible' \
212+
-v -r sx --color=yes -m 'deployment_community'
213+
214+
.PHONY: test/integration/certified
215+
test/integration/certified: ## Run certified-sync integration tests
216+
# if pytest is not found raise a warning and install it
217+
@which pytest || (echo "pytest not found, installing it now" && pip install -r integration_requirements.txt)
218+
@echo "Running certified-sync integration tests"
219+
HUB_LOCAL=1 \
220+
HUB_API_ROOT=http://localhost:5001/api/galaxy/ \
221+
HUB_USE_MOVE_ENDPOINT="true" \
222+
GALAXYKIT_SLEEP_SECONDS_POLLING=.5 \
223+
GALAXYKIT_SLEEP_SECONDS_ONETIME=.5 \
224+
GALAXYKIT_POLLING_MAX_ATTEMPTS=50 \
225+
GALAXY_SLEEP_SECONDS_POLLING=.5 \
226+
GALAXY_SLEEP_SECONDS_ONETIME=.5 \
227+
GALAXY_POLLING_MAX_ATTEMPTS=50 \
228+
pytest galaxy_ng/tests/integration \
229+
-p 'no:pulpcore' -p 'no:pulp_ansible' \
230+
-v -r sx --color=yes -m 'sync'
231+
232+
.PHONY: test/integration/insights
233+
test/integration/insights: ## Run insights integration tests
234+
# if pytest is not found raise a warning and install it
235+
@which pytest || (echo "pytest not found, installing it now" && pip install -r integration_requirements.txt)
236+
@echo "Running insights integration tests"
237+
HUB_LOCAL=1 \
238+
HUB_API_ROOT=http://localhost:8080/api/automation-hub/ \
239+
HUB_AUTH_URL=http://localhost:8080/auth/realms/redhat-external/protocol/openid-connect/token \
240+
HUB_USE_MOVE_ENDPOINT="true" \
241+
HUB_UPLOAD_SIGNATURES="true" \
242+
GALAXYKIT_SLEEP_SECONDS_POLLING=.5 \
243+
GALAXYKIT_SLEEP_SECONDS_ONETIME=.5 \
244+
GALAXYKIT_POLLING_MAX_ATTEMPTS=50 \
245+
GALAXY_SLEEP_SECONDS_POLLING=.5 \
246+
GALAXY_SLEEP_SECONDS_ONETIME=.5 \
247+
GALAXY_POLLING_MAX_ATTEMPTS=50 \
248+
pytest galaxy_ng/tests/integration \
249+
-p 'no:pulpcore' -p 'no:pulp_ansible' \
250+
-v -r sx --color=yes -m 'deployment_cloud or all'

dev/compose/Dockerfile.dev

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ ARG GNUPGHOME
77
ENV GNUPGHOME $GNUPGHOME
88

99
USER root
10+
RUN ${VIRTUAL_ENV}/bin/python3 -m pip install ipython ipdb django-extensions pulp-cli
1011

12+
USER galaxy
1113
RUN /app/dev/compose/signing/setup_gpg_workarounds.sh
1214

1315
RUN set -ex; \
@@ -20,5 +22,3 @@ RUN set -ex; \
2022
chmod +x /var/lib/pulp/scripts/*_sign.sh
2123

2224
RUN /app/dev/compose/signing/setup_gpg_keys.sh
23-
24-
RUN ${VIRTUAL_ENV}/bin/python3 -m pip install ipython ipdb django-extensions pulp-cli

dev/compose/aap.yaml

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
x-common-env: &common-env
22

3-
GNUPGHOME: /root/.gnupg/
3+
GNUPGHOME: /etc/pulp/gnupg/
44

55
DJANGO_SUPERUSER_USERNAME: admin
66
DJANGO_SUPERUSER_EMAIL: [email protected]
@@ -89,6 +89,8 @@ services:
8989
build:
9090
context: ../../
9191
dockerfile: Dockerfile
92+
args:
93+
USER_ID: "${USER_ID:-1000}"
9294
image: "localhost/galaxy_ng/galaxy_ng:base"
9395

9496
base_img_dev: # Extends base_img with extra files and dev tools
@@ -152,6 +154,7 @@ services:
152154
pulpcore-manager createsuperuser --noinput || true;
153155
154156
touch /var/lib/pulp/.migrated;
157+
chown -R galaxy:galaxy /etc/pulp /var/lib/pulp;
155158
"
156159
157160
api:
@@ -172,7 +175,7 @@ services:
172175
networks:
173176
- default
174177
- service-mesh
175-
user: root
178+
user: galaxy
176179
<<: *debugging
177180
command: |
178181
bash -c "
@@ -200,7 +203,7 @@ services:
200203
networks:
201204
- default
202205
- service-mesh
203-
user: root
206+
user: galaxy
204207
<<: *debugging
205208
command: |
206209
bash -c "
@@ -223,7 +226,7 @@ services:
223226
- "../../:/app"
224227
environment:
225228
<<: *common-env
226-
user: root
229+
user: galaxy
227230
<<: *debugging
228231
command: |
229232
bash -c "
@@ -250,7 +253,7 @@ services:
250253
- "../../:/app"
251254
environment:
252255
<<: *common-env
253-
user: root
256+
user: galaxy
254257
<<: *debugging
255258
command: |
256259
bash -c "

dev/compose/certified-sync.yaml

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
x-common-env: &common-env
22

3-
GNUPGHOME: /root/.gnupg/
3+
GNUPGHOME: /etc/pulp/gnupg/
44

55
DJANGO_SUPERUSER_USERNAME: admin
66
DJANGO_SUPERUSER_EMAIL: [email protected]
@@ -110,6 +110,8 @@ services:
110110
build:
111111
context: ../../
112112
dockerfile: Dockerfile
113+
args:
114+
USER_ID: "${USER_ID:-1000}"
113115
image: "localhost/galaxy_ng/galaxy_ng:base"
114116

115117
base_img_dev: # Extends base_img with extra files and dev tools
@@ -175,6 +177,7 @@ services:
175177
pulpcore-manager createsuperuser --noinput || true;
176178
177179
touch /var/lib/pulp/.migrated;
180+
chown -R galaxy:galaxy /etc/pulp /var/lib/pulp;
178181
"
179182
180183
standalone-api:
@@ -195,7 +198,7 @@ services:
195198
networks:
196199
- default
197200
- service-mesh
198-
user: root
201+
user: galaxy
199202
<<: *debugging
200203
command: |
201204
bash -c "
@@ -222,7 +225,7 @@ services:
222225
networks:
223226
- default
224227
- service-mesh
225-
user: root
228+
user: galaxy
226229
<<: *debugging
227230
command: |
228231
bash -c "
@@ -244,7 +247,7 @@ services:
244247
- "../../:/app"
245248
environment:
246249
<<: *standalone-env
247-
user: root
250+
user: galaxy
248251
<<: *debugging
249252
command: |
250253
bash -c "
@@ -271,7 +274,7 @@ services:
271274
- "../../:/app"
272275
environment:
273276
<<: *standalone-env
274-
user: root
277+
user: galaxy
275278
<<: *debugging
276279
command: |
277280
bash -c "
@@ -394,6 +397,7 @@ services:
394397
pulpcore-manager createsuperuser --noinput || true;
395398
396399
touch /var/lib/pulp/.migrated;
400+
chown -R galaxy:galaxy /etc/pulp /var/lib/pulp;
397401
"
398402
399403
insights-proxy:
@@ -426,7 +430,7 @@ services:
426430
networks:
427431
- default
428432
- service-mesh
429-
user: root
433+
user: galaxy
430434
<<: *debugging
431435
command: |
432436
bash -c "
@@ -453,7 +457,7 @@ services:
453457
networks:
454458
- default
455459
- service-mesh
456-
user: root
460+
user: galaxy
457461
<<: *debugging
458462
command: |
459463
bash -c "
@@ -475,7 +479,7 @@ services:
475479
- "../../:/app"
476480
environment:
477481
<<: *insights-env
478-
user: root
482+
user: galaxy
479483
<<: *debugging
480484
command: |
481485
bash -c "
@@ -502,7 +506,7 @@ services:
502506
- "../../:/app"
503507
environment:
504508
<<: *insights-env
505-
user: root
509+
user: galaxy
506510
<<: *debugging
507511
command: |
508512
bash -c "

dev/compose/community.yaml

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
x-common-env: &common-env
22

3-
GNUPGHOME: /root/.gnupg/
3+
GNUPGHOME: /etc/pulp/gnupg/
44
GALAXY_IMPORTER_CONFIG: /src/galaxy_ng/profiles/community/galaxy-importer/galaxy-importer.cfg
55

66
DJANGO_SUPERUSER_USERNAME: admin
@@ -99,6 +99,8 @@ services:
9999
build:
100100
context: ../../
101101
dockerfile: Dockerfile
102+
args:
103+
USER_ID: "${USER_ID:-1000}"
102104
image: "localhost/galaxy_ng/galaxy_ng:base"
103105

104106
base_img_dev: # Extends base_img with extra files and dev tools
@@ -174,6 +176,7 @@ services:
174176
pulpcore-manager createsuperuser --noinput || true;
175177
176178
touch /var/lib/pulp/.migrated;
179+
chown -R galaxy:galaxy /etc/pulp /var/lib/pulp;
177180
"
178181
179182
api:
@@ -194,7 +197,7 @@ services:
194197
networks:
195198
- default
196199
- service-mesh
197-
user: root
200+
user: galaxy
198201
<<: *debugging
199202
command: |
200203
bash -c "
@@ -221,7 +224,7 @@ services:
221224
networks:
222225
- default
223226
- service-mesh
224-
user: root
227+
user: galaxy
225228
<<: *debugging
226229
command: |
227230
bash -c "
@@ -243,7 +246,7 @@ services:
243246
- "../../:/app"
244247
environment:
245248
<<: *common-env
246-
user: root
249+
user: galaxy
247250
<<: *debugging
248251
command: |
249252
bash -c "
@@ -266,7 +269,7 @@ services:
266269
- "../../:/app"
267270
environment:
268271
<<: *common-env
269-
user: root
272+
user: galaxy
270273
<<: *debugging
271274
command: |
272275
bash -c "

0 commit comments

Comments
 (0)