Skip to content

Commit c7dfcac

Browse files
committed
Improve image building
1 parent 5e281d0 commit c7dfcac

File tree

3 files changed

+34
-46
lines changed

3 files changed

+34
-46
lines changed
Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,28 @@
1-
FROM {{ ci_base | default(pulp_default_container) }}
1+
FROM {{ image.ci_base }}
2+
{%- if image.webserver_snippet %}
23

3-
# Add source directories to container
4-
{% for item in plugins %}
5-
ADD ./{{ item.name }} ./{{ item.name }}
6-
{% endfor %}
4+
ADD .{{ plugin_name | snake }}/app/webserver_snippets/nginx.conf" /etc/nginx/pulp/{{ plugin_name }}.conf
5+
{%- endif %}
6+
7+
{%- for item in extra_files | default([]) %}
78

8-
{% for item in extra_files | default([]) %}
99
ADD ./{{ item.origin }} {{ item.destination }}
10-
{% endfor %}
10+
{%- endfor %}
1111

1212
# This MUST be the ONLY call to pip install in inside the container.
1313
RUN pip3 install --upgrade pip setuptools wheel && \
1414
rm -rf /root/.cache/pip && \
15-
pip3 install
16-
{%- if s3_test | default(false) -%}
17-
{{ " " }}git+https://github.com/gerrod3/botocore.git@fix-100-continue
15+
pip3 install {{ image.source }}
16+
{%- if image.upperbounds | default(false) -%}
17+
{{ " " }}-c ./{{ plugin_name }}/upperbounds_constraints.txt
1818
{%- endif -%}
19-
{%- for item in plugins -%}
20-
{{ " " }}{{ item.source }}
21-
{%- if item.upperbounds | default(false) -%}
22-
{{ " " }}-c ./{{ item.name }}/upperbounds_constraints.txt
19+
{%- if image.lowerbounds | default(false) -%}
20+
{{ " " }}-c ./{{ plugin_name }}/lowerbounds_constraints.txt
2321
{%- endif -%}
24-
{%- if item.lowerbounds | default(false) -%}
25-
{{ " " }}-c ./{{ item.name }}/lowerbounds_constraints.txt
22+
{%- if image.ci_requirements | default(false) -%}
23+
{{ " " }}-r ./{{ plugin_name }}/ci_requirements.txt
2624
{%- endif -%}
27-
{%- if item.ci_requirements | default(false) -%}
28-
{{ " " }}-r ./{{ item.name }}/ci_requirements.txt
29-
{%- endif -%}
30-
{%- endfor %}
31-
{{ " " }}-c ./{{ plugins[0].name }}/.ci/assets/ci_constraints.txt && \
25+
{{ " " }}-c ./{{ plugin_name }}/.ci/assets/ci_constraints.txt && \
3226
rm -rf /root/.cache/pip
3327

3428
{% if pulp_env is defined and pulp_env %}
@@ -48,9 +42,4 @@ RUN PULP_STATIC_ROOT=/var/lib/operator/static/ PULP_CONTENT_ORIGIN=localhost \
4842
/usr/local/bin/pulpcore-manager collectstatic --clear --noinput --link
4943
USER root:root
5044

51-
{% for item in plugins %}
52-
RUN export plugin_path="$(pip3 show {{ item.name }} | sed -n -e 's/Location: //p')/{{ item.name }}" && \
53-
ln $plugin_path/app/webserver_snippets/nginx.conf /etc/nginx/pulp/{{ item.name }}.conf || true
54-
{% endfor %}
55-
5645
ENTRYPOINT ["/init"]

templates/github/.ci/ansible/build_container.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
# Ansible playbook to create the pulp service containers image
22
---
3-
- hosts: localhost
3+
- hosts: "localhost"
44
gather_facts: false
55
vars_files:
6-
- vars/main.yaml
6+
- "vars/main.yaml"
77
tasks:
88
- name: "Generate Containerfile from template"
9-
template:
10-
src: Containerfile.j2
11-
dest: Containerfile
12-
9+
ansible.builtin.template:
10+
src: "Containerfile.j2"
11+
dest: "Containerfile"
1312
- name: "Build pulp image"
1413
# We build from the ../.. (parent dir of pulpcore git repo) Docker build
1514
# "context" so that repos like pulp-smash are accessible to Docker

templates/github/.github/workflows/scripts/before_install.sh.j2

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ COMPONENT_SOURCE="./{{ plugin_name }}/dist/{{ plugin_name | snake }}-${COMPONENT
2424
{%- set PULPCORE_PREFIX = "" if plugin_name == "pulpcore" else " pulpcore" %}
2525
{%- if test_s3 %}
2626
if [ "$TEST" = "s3" ]; then
27-
COMPONENT_SOURCE="${COMPONENT_SOURCE}{{ PULPCORE_PREFIX }}[s3]"
27+
COMPONENT_SOURCE="${COMPONENT_SOURCE}{{ PULPCORE_PREFIX }}[s3] git+https://github.com/gerrod3/botocore.git@fix-100-continue"
2828
fi
2929
{%- endif %}
3030
{%- if test_azure %}
@@ -59,34 +59,34 @@ mkdir -p .ci/ansible/vars
5959
cat > .ci/ansible/vars/main.yaml << VARSYAML
6060
---
6161
scenario: "${TEST}"
62+
plugin_name: "{{ plugin_name }}"
6263
legacy_component_name: "{{ plugin_name | snake }}"
6364
component_name: "{{ plugin_app_label }}"
6465
component_version: "${COMPONENT_VERSION}"
6566
pulp_env: {{ pulp_env | tojson }}
6667
pulp_settings: {{ pulp_settings | tojson }}
6768
pulp_scheme: "{{ pulp_scheme }}"
68-
{%- if ci_base_image.count(":") %}
69-
pulp_default_container: "{{ ci_base_image }}"
70-
{% else %}
71-
pulp_default_container: "{{ ci_base_image + ":latest" }}"
72-
{% endif -%}
7369
api_root: "${PULP_API_ROOT}"
7470
image:
7571
name: "pulp"
7672
tag: "ci_build"
77-
plugins:
78-
- name: "{{ plugin_name }}"
79-
source: "${COMPONENT_SOURCE}"
80-
ci_requirements: $(test -f ci_requirements.txt && echo -n true || echo -n false)
81-
upperbounds: $(test "${TEST}" = "pulp" && echo -n true || echo -n false)
82-
lowerbounds: $(test "${TEST}" = "lowerbounds" && echo -n true || echo -n false)
83-
{%- if extra_files %}
73+
{%- if ci_base_image.count(":") %}
74+
ci_base: "{{ ci_base_image }}"
75+
{% else %}
76+
ci_base: "{{ ci_base_image + ":latest" }}"
77+
{% endif -%}
78+
source: "${COMPONENT_SOURCE}"
79+
ci_requirements: $(test -f ci_requirements.txt && echo -n true || echo -n false)
80+
upperbounds: $(test "${TEST}" = "pulp" && echo -n true || echo -n false)
81+
lowerbounds: $(test "${TEST}" = "lowerbounds" && echo -n true || echo -n false)
82+
webserver_snippet: $(test -f {{ plugin_name | snake }}/app/webserver_snippets/nginx.conf && echo -n true || echo -n false )
8483
extra_files:
84+
- origin: "{{ plugin_name }}"
85+
destination: "{{ plugin_name }}"
8586
{%- for item in extra_files %}
8687
- origin: "{{ item.origin }}"
8788
destination: "{{ item.destination }}"
8889
{%- endfor %}
89-
{%- endif %}
9090
services:
9191
- name: "pulp"
9292
image: "pulp:ci_build"

0 commit comments

Comments
 (0)