Skip to content
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
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.github
.idea
agent
zz_*
vendor/
scripts/
Expand Down
64 changes: 53 additions & 11 deletions inventory.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,47 @@ images:
context: .
template_context: scripts/dev/templates/agent

inputs:
- agent_version
- tools_version

stages:
- name: agent-ubuntu-context
task_type: docker_build
dockerfile: scripts/dev/templates/agent/Dockerfile.builder
tags: ["ubuntu"]
buildargs:
agent_version: $(inputs.params.agent_version)
tools_version: $(inputs.params.tools_version)
agent_distro: linux_x86_64
tools_distro: ubuntu1604-x86_64

output:
- registry: $(inputs.params.registry)/agent-ubuntu-context-dev
tag: $(inputs.params.version_id)

- name: agent-template-ubuntu
task_type: dockerfile_template
distro: ubuntu
tags: ["ubuntu"]
distro: ubuntu

# TODO: remove - this is only here as sonar raises a key error on version_id
# if no other inputs are specified.
inputs:
- agent_version
- tools_version
- tools_distro
- agent_distro
- noop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you fixed this already :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we haven't yet released 0.10.0, but let's do that now, no harm!


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

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

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

buildargs:
imagebase: $(inputs.params.registry)/agent-ubuntu-context-dev:$(inputs.params.version_id)

labels:
quay.expires-after: 48h

Expand All @@ -40,26 +61,47 @@ images:
context: .
template_context: scripts/dev/templates/agent

inputs:
- agent_version
- tools_version

stages:
- name: agent-ubi-context
task_type: docker_build
dockerfile: scripts/dev/templates/agent/Dockerfile.builder
tags: ["ubi"]
buildargs:
agent_version: $(inputs.params.agent_version)
tools_version: $(inputs.params.tools_version)
agent_distro: rhel7_x86_64
tools_distro: rhel70-x86_64

output:
- registry: $(inputs.params.registry)/agent-ubi-context-dev
tag: $(inputs.params.version_id)


- name: agent-template-ubi
task_type: dockerfile_template
distro: ubi
tags: ["ubi"]

# TODO: remove - this is only here as sonar raises a key error on version_id
# if no other inputs are specified.
inputs:
- agent_version
- tools_version
- tools_distro
- agent_distro
- noop

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


- name: agent-ubi-build
task_type: docker_build
dockerfile: scripts/dev/templates/agent/Dockerfile.ubi-$(inputs.params.version_id)
tags: ["ubi"]
dockerfile: scripts/dev/templates/agent/Dockerfile.ubi-$(inputs.params.version_id)

buildargs:
imagebase: $(inputs.params.registry)/agent-ubi-context-dev:$(inputs.params.version_id)

labels:
quay.expires-after: 48h
Expand Down
5 changes: 1 addition & 4 deletions pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ def build_agent_image_ubi(config: DevConfig) -> None:
image_name = "agent-ubi"
with open("release.json") as f:
release = json.loads(f.read())

args = {
"agent_version": release["agent"]["version"],
"tools_version": release["agent"]["tools_version"],
"tools_distro": "rhel70-x86_64",
"agent_distro": "rhel7_x86_64",
"registry": config.repo_url,
}

Expand All @@ -48,8 +47,6 @@ def build_agent_image_ubuntu(config: DevConfig) -> None:
args = {
"agent_version": release["agent"]["version"],
"tools_version": release["agent"]["tools_version"],
"tools_distro": "ubuntu1604-x86_64",
"agent_distro": "linux_x86_64",
"registry": config.repo_url,
}

Expand Down
11 changes: 11 additions & 0 deletions scripts/dev/templates/agent/Dockerfile.builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM scratch

ARG agent_version
ARG agent_distro
ARG tools_distro
ARG tools_version

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
ADD https://downloads.mongodb.org/tools/db/mongodb-database-tools-${tools_distro}-${tools_version}.tgz /data/mongodb-tools.tgz

ADD agent/LICENSE /data/licenses
39 changes: 21 additions & 18 deletions scripts/dev/templates/agent/Dockerfile.template
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
ARG imagebase
FROM ${imagebase} as base

FROM {{base_image}}

{% block packages -%}
{% endblock -%}

RUN mkdir -p agent \
&& 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 \
&& tar xfz agent/mongodb-agent.tar.gz \
&& mv mongodb-mms-automation-agent-*/mongodb-mms-automation-agent agent/mongodb-agent \
&& chmod +x agent/mongodb-agent \
RUN mkdir -p /agent \
&& mkdir -p /var/lib/mongodb-mms-automation \
&& mkdir -p /var/log/mongodb-mms-automation/ \
&& chmod -R +wr /var/log/mongodb-mms-automation/ \
# ensure that the agent user can write the logs in OpenShift
&& touch /var/log/mongodb-mms-automation/readiness.log \
&& chmod ugo+rw /var/log/mongodb-mms-automation/readiness.log


COPY --from=base /data/mongodb-agent.tar.gz /agent
COPY --from=base /data/mongodb-tools.tgz /agent

RUN tar xfz /agent/mongodb-agent.tar.gz \
&& mv mongodb-mms-automation-agent-*/mongodb-mms-automation-agent /agent/mongodb-agent \
&& chmod +x /agent/mongodb-agent \
&& mkdir -p /var/lib/automation/config \
&& chmod -R +r /var/lib/automation/config \
&& rm agent/mongodb-agent.tar.gz \
&& rm /agent/mongodb-agent.tar.gz \
&& rm -r mongodb-mms-automation-agent-*

RUN mkdir -p /var/lib/mongodb-mms-automation \
&& mkdir -p /var/log/mongodb-mms-automation/ \
&& chmod -R +wr /var/log/mongodb-mms-automation/ \
# ensure that the agent user can write the logs in OpenShift
&& touch /var/log/mongodb-mms-automation/readiness.log \
&& chmod ugo+rw /var/log/mongodb-mms-automation/readiness.log

# Install MongoDB tools. The agent will automatically search the folder and find the binaries.
RUN curl --fail --retry 3 --silent https://downloads.mongodb.org/tools/db/mongodb-database-tools-{{tools_distro}}-{{tools_version}}.tgz -o mongodb-tools.tgz \
&& tar xfz mongodb-tools.tgz --directory /var/lib/mongodb-mms-automation/ \
&& rm mongodb-tools.tgz
RUN tar xfz /agent/mongodb-tools.tgz --directory /var/lib/mongodb-mms-automation/ && rm /agent/mongodb-tools.tgz

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