Skip to content

Commit 837aaec

Browse files
authored
CLOUDP-83092: Add context images for agents. (#435)
1 parent 2021ae6 commit 837aaec

File tree

5 files changed

+86
-34
lines changed

5 files changed

+86
-34
lines changed

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
.github
22
.idea
3-
agent
43
zz_*
54
vendor/
65
scripts/

inventory.yaml

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,47 @@ images:
77
context: .
88
template_context: scripts/dev/templates/agent
99

10+
inputs:
11+
- agent_version
12+
- tools_version
13+
1014
stages:
15+
- name: agent-ubuntu-context
16+
task_type: docker_build
17+
dockerfile: scripts/dev/templates/agent/Dockerfile.builder
18+
tags: ["ubuntu"]
19+
buildargs:
20+
agent_version: $(inputs.params.agent_version)
21+
tools_version: $(inputs.params.tools_version)
22+
agent_distro: linux_x86_64
23+
tools_distro: ubuntu1604-x86_64
24+
25+
output:
26+
- registry: $(inputs.params.registry)/agent-ubuntu-context-dev
27+
tag: $(inputs.params.version_id)
28+
1129
- name: agent-template-ubuntu
1230
task_type: dockerfile_template
13-
distro: ubuntu
1431
tags: ["ubuntu"]
32+
distro: ubuntu
1533

34+
# TODO: remove - this is only here as sonar raises a key error on version_id
35+
# if no other inputs are specified.
1636
inputs:
17-
- agent_version
18-
- tools_version
19-
- tools_distro
20-
- agent_distro
37+
- noop
2138

2239
output:
2340
- dockerfile: scripts/dev/templates/agent/Dockerfile.ubuntu-$(inputs.params.version_id)
2441

2542
- name: agent-ubuntu-build
2643
task_type: docker_build
27-
dockerfile: scripts/dev/templates/agent/Dockerfile.ubuntu-$(inputs.params.version_id)
2844
tags: ["ubuntu"]
2945

46+
dockerfile: scripts/dev/templates/agent/Dockerfile.ubuntu-$(inputs.params.version_id)
47+
48+
buildargs:
49+
imagebase: $(inputs.params.registry)/agent-ubuntu-context-dev:$(inputs.params.version_id)
50+
3051
labels:
3152
quay.expires-after: 48h
3253

@@ -40,26 +61,47 @@ images:
4061
context: .
4162
template_context: scripts/dev/templates/agent
4263

64+
inputs:
65+
- agent_version
66+
- tools_version
67+
4368
stages:
69+
- name: agent-ubi-context
70+
task_type: docker_build
71+
dockerfile: scripts/dev/templates/agent/Dockerfile.builder
72+
tags: ["ubi"]
73+
buildargs:
74+
agent_version: $(inputs.params.agent_version)
75+
tools_version: $(inputs.params.tools_version)
76+
agent_distro: rhel7_x86_64
77+
tools_distro: rhel70-x86_64
78+
79+
output:
80+
- registry: $(inputs.params.registry)/agent-ubi-context-dev
81+
tag: $(inputs.params.version_id)
82+
83+
4484
- name: agent-template-ubi
4585
task_type: dockerfile_template
4686
distro: ubi
4787
tags: ["ubi"]
4888

89+
# TODO: remove - this is only here as sonar raises a key error on version_id
90+
# if no other inputs are specified.
4991
inputs:
50-
- agent_version
51-
- tools_version
52-
- tools_distro
53-
- agent_distro
92+
- noop
5493

5594
output:
5695
- dockerfile: scripts/dev/templates/agent/Dockerfile.ubi-$(inputs.params.version_id)
5796

5897

5998
- name: agent-ubi-build
6099
task_type: docker_build
61-
dockerfile: scripts/dev/templates/agent/Dockerfile.ubi-$(inputs.params.version_id)
62100
tags: ["ubi"]
101+
dockerfile: scripts/dev/templates/agent/Dockerfile.ubi-$(inputs.params.version_id)
102+
103+
buildargs:
104+
imagebase: $(inputs.params.registry)/agent-ubi-context-dev:$(inputs.params.version_id)
63105

64106
labels:
65107
quay.expires-after: 48h

pipeline.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@ def build_agent_image_ubi(config: DevConfig) -> None:
2424
image_name = "agent-ubi"
2525
with open("release.json") as f:
2626
release = json.loads(f.read())
27+
2728
args = {
2829
"agent_version": release["agent"]["version"],
2930
"tools_version": release["agent"]["tools_version"],
30-
"tools_distro": "rhel70-x86_64",
31-
"agent_distro": "rhel7_x86_64",
3231
"registry": config.repo_url,
3332
}
3433

@@ -48,8 +47,6 @@ def build_agent_image_ubuntu(config: DevConfig) -> None:
4847
args = {
4948
"agent_version": release["agent"]["version"],
5049
"tools_version": release["agent"]["tools_version"],
51-
"tools_distro": "ubuntu1604-x86_64",
52-
"agent_distro": "linux_x86_64",
5350
"registry": config.repo_url,
5451
}
5552

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM scratch
2+
3+
ARG agent_version
4+
ARG agent_distro
5+
ARG tools_distro
6+
ARG tools_version
7+
8+
ADD https://mciuploads.s3.amazonaws.com/mms-automation/mongodb-mms-build-agent/builds/automation-agent/prod/mongodb-mms-automation-agent-${agent_version}.${agent_distro}.tar.gz /data/mongodb-agent.tar.gz
9+
ADD https://downloads.mongodb.org/tools/db/mongodb-database-tools-${tools_distro}-${tools_version}.tgz /data/mongodb-tools.tgz
10+
11+
ADD agent/LICENSE /data/licenses
Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
1+
ARG imagebase
2+
FROM ${imagebase} as base
3+
14
FROM {{base_image}}
25

36
{% block packages -%}
47
{% endblock -%}
58

6-
RUN mkdir -p agent \
7-
&& curl --fail --retry 3 --silent https://mciuploads.s3.amazonaws.com/mms-automation/mongodb-mms-build-agent/builds/automation-agent/prod/mongodb-mms-automation-agent-{{agent_version}}.{{agent_distro}}.tar.gz -o agent/mongodb-agent.tar.gz \
8-
&& tar xfz agent/mongodb-agent.tar.gz \
9-
&& mv mongodb-mms-automation-agent-*/mongodb-mms-automation-agent agent/mongodb-agent \
10-
&& chmod +x agent/mongodb-agent \
9+
RUN mkdir -p /agent \
10+
&& mkdir -p /var/lib/mongodb-mms-automation \
11+
&& mkdir -p /var/log/mongodb-mms-automation/ \
12+
&& chmod -R +wr /var/log/mongodb-mms-automation/ \
13+
# ensure that the agent user can write the logs in OpenShift
14+
&& touch /var/log/mongodb-mms-automation/readiness.log \
15+
&& chmod ugo+rw /var/log/mongodb-mms-automation/readiness.log
16+
17+
18+
COPY --from=base /data/mongodb-agent.tar.gz /agent
19+
COPY --from=base /data/mongodb-tools.tgz /agent
20+
21+
RUN tar xfz /agent/mongodb-agent.tar.gz \
22+
&& mv mongodb-mms-automation-agent-*/mongodb-mms-automation-agent /agent/mongodb-agent \
23+
&& chmod +x /agent/mongodb-agent \
1124
&& mkdir -p /var/lib/automation/config \
1225
&& chmod -R +r /var/lib/automation/config \
13-
&& rm agent/mongodb-agent.tar.gz \
26+
&& rm /agent/mongodb-agent.tar.gz \
1427
&& rm -r mongodb-mms-automation-agent-*
1528

16-
RUN mkdir -p /var/lib/mongodb-mms-automation \
17-
&& mkdir -p /var/log/mongodb-mms-automation/ \
18-
&& chmod -R +wr /var/log/mongodb-mms-automation/ \
19-
# ensure that the agent user can write the logs in OpenShift
20-
&& touch /var/log/mongodb-mms-automation/readiness.log \
21-
&& chmod ugo+rw /var/log/mongodb-mms-automation/readiness.log
22-
23-
# Install MongoDB tools. The agent will automatically search the folder and find the binaries.
24-
RUN curl --fail --retry 3 --silent https://downloads.mongodb.org/tools/db/mongodb-database-tools-{{tools_distro}}-{{tools_version}}.tgz -o mongodb-tools.tgz \
25-
&& tar xfz mongodb-tools.tgz --directory /var/lib/mongodb-mms-automation/ \
26-
&& rm mongodb-tools.tgz
29+
RUN tar xfz /agent/mongodb-tools.tgz --directory /var/lib/mongodb-mms-automation/ && rm /agent/mongodb-tools.tgz
2730

2831
USER 2000
29-
CMD ["agent/mongodb-agent", "-cluster=/var/lib/automation/config/automation-config.json"]
32+
CMD ["/agent/mongodb-agent", "-cluster=/var/lib/automation/config/automation-config.json"]

0 commit comments

Comments
 (0)