Skip to content
This repository has been archived by the owner on Mar 18, 2019. It is now read-only.

Simplify docker images down to three variants #44

Merged
merged 29 commits into from
Mar 8, 2017
Merged

Conversation

lox
Copy link
Contributor

@lox lox commented Jan 28, 2017

This extends on #38.

It simplifies down to three basic alpine based images, latest (stable), beta and experimental. Each contains the relevant agent and some basic stuff like su-exec, docker (client 1.13), jq and curl.

Images end up at around 230 MB.

@lox
Copy link
Contributor Author

lox commented Jan 28, 2017

@toolmantim it looks like the edge image at https://download.buildkite.com/agent/experimental/3.0-beta.10.1323/buildkite-agent-linux-amd64 is returning a dynamically linked binary, so it's failing the test.

This at least verifies that it's worth having a test rather than auto-building via Docker Hub which I was seriously considering :)

@lox
Copy link
Contributor Author

lox commented Jan 28, 2017

I updated to the latest experimental build and everything works fine.

@lox
Copy link
Contributor Author

lox commented Jan 28, 2017

Using https://docs.docker.com/compose/install/#install-as-a-container for installing docker-compose.

@toolmantim
Copy link
Contributor

Nice work! What was too hard about a local install of docker-compose?

This at least verifies that it's worth having a test rather than auto-building via Docker Hub which I was seriously considering :)

Something we can do is trigger the Docker Hub build from the Buildkite pipeline (they have a URL you can curl to kick it off), rather than on the GitHub change. If we wanted to do that.

@sj26
Copy link
Member

sj26 commented Jan 30, 2017

This is looking nice! 👌

done

# variants of beta 3.0-beta.9
for tag in 3.0-beta.9 3.0 3 ; do
Copy link
Contributor

Choose a reason for hiding this comment

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

beta 9 or 16?

@lox
Copy link
Contributor Author

lox commented Feb 9, 2017

So what do we have to do to move this forward?

@lox
Copy link
Contributor Author

lox commented Feb 9, 2017

I've pushed images to https://hub.docker.com/r/lox24/buildkite-agent/ for this PR.

@lox lox changed the title [WIP] Clean up images - Lox Clean up images - Lox Feb 9, 2017
@lox
Copy link
Contributor Author

lox commented Feb 9, 2017

Going to do some testing on a PR on https://github.com/buildkite/elastic-ci-stack-for-aws

@lox
Copy link
Contributor Author

lox commented Feb 9, 2017

Btw @toolmantim, the hard bit about docker-compose is that it needs python installed. The current solution is a shim script that calls a docker-compose docker image, but I think that might end up being too complicated.

@toolmantim
Copy link
Contributor

toolmantim commented Feb 13, 2017

This seems almost ready for release!

The labels look the same, and I can't spot anything else that's a breaking change, aside from removing DIND.

I wonder what the best solution is for people wanting to add DIND support? Perhaps building your own custom image?

FROM buildkite/agent

ADD https://raw.githubusercontent.com/docker/docker/v.13.1/hack/dind /usr/local/bin
RUN chmod +x /usr/local/bin/dind

# copy and pasted from buildkite/agent base, with "dind" added
ENTRYPOINT ["dind", "/sbin/tini", "-g", "--", "ssh-env-config.sh", "/usr/local/bin/buildkite-agent"]

@toolmantim
Copy link
Contributor

toolmantim commented Feb 13, 2017

Related to @blueimp’s feedback in #38, perhaps instead of entrypoint.d we just wrap up our ENTRYPOINT commands in a single buildkite-agent-entrypoint executable so it can easily be called from images that build upon it?

So the above DIND example would become:

FROM buildkite/agent

ADD https://raw.githubusercontent.com/docker/docker/v.13.1/hack/dind /usr/local/bin
RUN chmod +x /usr/local/bin/dind

ENTRYPOINT ["dind", "buildkite-agent-entrypoint"]

Or does tini need to be at the beginning?

@toolmantim toolmantim mentioned this pull request Feb 14, 2017
2 tasks
@toolmantim toolmantim changed the title Clean up images - Lox Clean up images - take II Feb 14, 2017
@lox
Copy link
Contributor Author

lox commented Feb 15, 2017

IMO this is good to go. We might just need some docs updated.

@blueimp
Copy link
Contributor

blueimp commented Feb 15, 2017

@toolmantim
Yes, tini should be the first entrypoint binary so it can run as PID 1 and reap zombies.

@toolmantim
Copy link
Contributor

Thanks @blueimp.

Okay, so I believe the updated DIND example would be this then:

FROM buildkite/agent

RUN curl -sL https://github.com/docker/docker/raw/v1.13.1/hack/dind > /docker-entrypoint.d/dind \
    && chmod +x /docker-entrypoint.d/dind

README.md Outdated

There is a wrapper script in the container that invokes a container for docker-compose. This is done to keep the image small, as docker-compose requires a python environment.

Using it requires that you mount a volume into the container for `/buildkite`, and pass in the name of that volume as an env called ``.
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this mean that you can now only use docker-compose if you've created a docker volume and mounted it into /buildkite? Whereas before, it'd Just Work™?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh this needs to be updated. I ended up going back to installing docker-compose directly. Adds about 90M to the image, but I think it's worth it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool! I think so too.

@lox lox changed the title Clean up images - take II Simplify docker images down to three variants Feb 19, 2017
README.md Outdated
@@ -4,20 +4,18 @@ Docker images for the [Buildkite Agent](https://github.com/buildkite/agent). A v

> If you don't need to run the agent on a purely Docker-based operating system (such as Kubernetes), and instead just want to [run your builds inside Docker containers](https://buildkite.com/docs/guides/docker-containerized-builds), then we recommend using one of the standard installers (such as `apt`). See the [containerized builds guide](https://buildkite.com/docs/guides/docker-containerized-builds) for more information.

The Buildkite Agent is available via an Alpine Linux based image, with either the stable, beta or experimental versions of the Buildkite Agent, with or without docker:
The Buildkite Agent is built on Alpine Linux, with either the stable, beta or experimental versions of the Buildkite Agent, with or without docker:
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 we axe with or without docker now yeah?

README.md Outdated
@@ -76,6 +65,10 @@ A less-recommended approach is to use the built-in [docker-ssh-env-config](https

Another approach is to use the [environment agent hook](https://buildkite.com/docs/agent/hooks) to pull down the key into the container’s file system before the `git checkout` occurs. Note: the key will exist in Docker’s file system unless it is destroyed.

## Customizing the image on boot

The default entrypoint will look for any scripts in `/docker-entrypoint.d/` and run them. This allows for bootstrap scripts to be mounted into the agent to install things (via apk or pip) before the agent starts.
Copy link
Contributor

Choose a reason for hiding this comment

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

What about:

## Entrypoint customizations

The entrypoint uses `tini` to correctly pass signals to, and kill, sub-processes. Instead of redefining `ENTRYPOINT` we recommend you copy executable scripts into `/docker-entrypoint.d/`. All executable scripts in that directory will be executed in alphanumeric order.

README.md Outdated

If in doubt, go with `buildkite/agent`—it's the smallest, most stable, and includes the docker client.
If in doubt, go with `buildkite/agent:latest`—it's the most stable, and includes the docker client.
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason for :latest here?

@toolmantim
Copy link
Contributor

@rimusz do you know how this will affect https://github.com/buildkite/helm-charts? This removes DIND support from buildkite/agent. I noticed "Helm Classic" is the old world, so perhaps we need to deprecate the helm-charts anyhow?

@rimusz
Copy link

rimusz commented Feb 21, 2017

@toolmantim do not worry about the DIND removal, helm-charts repo will get new Helm v2 chart soon

@lox
Copy link
Contributor Author

lox commented Feb 21, 2017

Updated docs @toolmantim

@toolmantim
Copy link
Contributor

This looks great!

The last bit that I can see is that now is that we're versioning these images with the agent version, and we'll need to update the release process too so it's automated from the agent pipeline.

At the moment we just trigger the Docker pipeline and it rebuilds all images every time, no matter if it's a stable, beta or experimental release.

We can probably feed the agent version and SHA256 to the pipeline via the trigger, and have it automatically update the Readme & Dockerfiles via the GitHub API, which would trigger its own build?

So, perhaps 2 pipelines…

  • pipeline.yml (tests and releases via GitHub events)
  • pipeline.bump-version.yml (GitHub API update via trigger from agent release pipeline)

The agent pipeline does the GitHub API stuff for the homebrew recipe at the moment. Though it's a bit gross.

@toolmantim
Copy link
Contributor

@rimusz thanks for clarifying!

Copy link
Contributor

@toolmantim toolmantim left a comment

Choose a reason for hiding this comment

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

🚀 It's time!

@lox lox merged commit f1df91c into master Mar 8, 2017
@lox lox deleted the simplify-images-lox branch March 8, 2017 00:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants