buildkite / docker-buildkite-agent

Previous home of buildkite/agent docker image scripts
26 stars 14 forks source link

Docker version doesn't match tags in older alpine-docker-1.x tags #35

Closed toolmantim closed 8 years ago

toolmantim commented 8 years ago

From @blueimp …

Hi there, I'd like to use the official alpine based docker images, but noticed that the tags don't match the docker version, e.g.:

docker run --rm --entrypoint docker buildkite/agent:alpine-docker-1.9 --version

returns

Docker version 1.11.1, build v1.11.1

I guess the reason is that the alpine image is based on alpine:edge which does not include docker 1.9 in it's repositories. The solution could be to install docker 1.9 from the alpine:3.3 repositories, as such:

apk --no-cache add \
    --repository http://dl-cdn.alpinelinux.org/alpine/v3.3/community/ \
    docker'<'1.10

I'd also suggest to switch to alpine:3.4, which includes tini and the DNS resolution fixes for which many were using alpine:edge already. Alternatively, you could also use docker:1.9 as base image, which is also based on alpine.

Another thing I'd like to see would be Docker images based on automated builds, as this makes it a little more transparent to what the image actually contains.

blueimp commented 8 years ago

Thanks @toolmantim. Sorry for posting to your slack channel instead of this issue tracker.

toolmantim commented 8 years ago

@blueimp that's okay! I didn't want the things you figured out to be lost in a sea of chat.

So we switched away from auto builds because it was getting too hard to maintain all the Dockerfiles… we had bug fixes being missed in some images. I agree it's hard to replicate and think about though. What's a good solution do you think?

toolmantim commented 8 years ago

Also, did you know what in this repo needs changing based on your base image suggestions? Totally fine if not, I'll just leave this here until I get a proper chance to dive in.

blueimp commented 8 years ago

From my point of view, auto builds actually help in automating. Especially since you can define linked repositories (usually base images) that will trigger a build.

I recommend using the official images whenever possible, e.g. using FROM docker:1.9.

The following would be a sample image for a Docker 1.9 based build with the buildkite agent:

FROM docker:1.9

# Install tini and remove its backwards compatibility wrapper:
RUN apk --no-cache add \
  --repository http://dl-cdn.alpinelinux.org/alpine/v3.4/community/ \
    tini \
  && rm /usr/bin/tini

RUN apk --no-cache add \
    # git, bash, openssh-client and curl are required for the buildkite-agent:
    git \
    bash \
    openssh-client \
    curl \
    # perl is required for git submodules support:
    perl \
    # py-pip is required to install docker-compose, awscli and awsebcli:
    py-pip \
  && pip install --upgrade \
    # Upgrade pip:
    pip \
    # Install docker-compose 1.7.1:
    docker-compose==1.7.1 \
  # Clean up obsolete files:
  && rm -rf \
    # Clean up any temporary files:
    /tmp/* \
    # Clean up the pip cache:
    /root/.cache \
    # Remove any compiled python files (compile on demand):
    `find / -regex '.*\.py[co]'`

# Install the buildkite agent:
RUN rm /usr/bin/wget && curl \
  https://raw.githubusercontent.com/buildkite/agent/master/install.sh | \
  DESTINATION=/buildkite bash \
  && ln -s /bin/busybox /usr/bin/wget

# Set the buildkite agent environment variables:
ENV PATH="$PATH":/buildkite/bin \
    BUILDKITE_BOOTSTRAP_SCRIPT_PATH=/buildkite/bootstrap.sh \
    BUILDKITE_BUILD_PATH=/buildkite/builds \
    BUILDKITE_HOOKS_PATH=/buildkite/hooks

# Start tini:
ENTRYPOINT ["tini", "--"]

# Start the buildkite agent:
CMD ["buildkite-agent", "start"]

We use this with the addition of some additional tools.

Images for different Docker versions would simply change the FROM line.

lox commented 8 years ago

I must have broken this in https://github.com/buildkite/docker-buildkite-agent/pull/34