Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic Consul raft discovery and formation #1

Merged
merged 12 commits into from
Oct 26, 2015
Merged

Conversation

misterbisson
Copy link
Contributor

No description provided.

curl \
bash \
ca-certificates && \
curl -Ls https://circle-artifacts.com/gh/andyshinn/alpine-pkg-glibc/6/artifacts/0/home/ubuntu/alpine-pkg-glibc/packages/x86_64/glibc-2.21-r2.apk > /tmp/glibc-2.21-r2.apk && \
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need glibc? this feels like something we should be documenting if we need it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair question. Honestly, that detail is copied in whole from https://github.com/gliderlabs/docker-consul/blob/legacy/Dockerfile#L6

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dekobon this might be a detail of interest to you, given your efforts in this space as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see it -- we're not building consul ourselves and instead we're using a build we're getting from "mitchelh", which was built against libc:

# ldd consul
        linux-vdso.so.1 (0x00007fffffd9c000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f535d222000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f535ce79000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f535d43f000)

(Go binaries aren't always entirely statically linked)

Copy link

Choose a reason for hiding this comment

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

Interesting. You curl in glibc. Wouldn't it be better to build Consul using Musl?

# Download and install Consul
# We are building it ourselves, because Alpine Linux doesn't use glibc
RUN export GOPATH=/go && \
    apk add --update go git gcc musl-dev make bash && \
    go get github.com/hashicorp/consul && \
    cd $GOPATH/src/github.com/hashicorp/consul && \
    git checkout -q --detach "v$CONSUL_VERSION" && \
    make && \
    mv bin/consul /bin && \
    rm -rf $GOPATH && \
    apk del go git gcc musl-dev make bash && \
    rm -rf /var/cache/apk/* && \
    addgroup consul && \
    adduser -D -G consul consul && \
    mkdir -p /data/consul && \
    chown -R consul:consul /data/consul

Putting aside @tgross 's hate for go get. This would give you a version of Consul that was compiled for the platform. For some reason, I trust a tagged Hashicorp release from github more than I do an entire glibc that I've curled into my environment. In fact, we should probably just create an APK for it and submit it to Alpine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wouldn't it be better to build Consul using Musl?

we should split the build container out from the container we ship though

Those sound like great ideas for a future version ;-)

Copy link
Contributor

Choose a reason for hiding this comment

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

It occurs to me that a musl build for something running DNS is something we'd want to test out quite a bit. One of the big behavioral differences between musl and libc is the DNS client library. Not sure if that'll turn out to be relevant for a Go program, but worth checking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to #2

Copy link

Choose a reason for hiding this comment

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

@tgross This line apk del go git gcc musl-dev make bash && \ mitigates the size of the container because we remove all of the dependencies within the same build step.

@misterbisson Yes, those are great ideas for a future version. Carry on with the good 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.

Please put all further discussion of an Alpine build in #2

@misterbisson
Copy link
Contributor Author

I've pushed the image to Docker Hub, so you can test this out with the ./start.sh script provided.

- 8400
- 8500
dns:
- 127.0.0.1
Copy link
Contributor

Choose a reason for hiding this comment

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

What's this bit for? edit, nevermind. Consul is acting as a recursive server

@tgross
Copy link
Contributor

tgross commented Oct 26, 2015

LGTM

misterbisson added a commit that referenced this pull request Oct 26, 2015
Automatic Consul raft discovery and formation
@misterbisson misterbisson merged commit 1d70dc4 into master Oct 26, 2015
@misterbisson misterbisson deleted the auto-raft branch November 25, 2015 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants