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

Add a docker recipe for rebar3 itself #2423

Merged
merged 1 commit into from
Nov 17, 2020
Merged

Conversation

lrascao
Copy link
Contributor

@lrascao lrascao commented Nov 5, 2020

Based on the closest Alpine Erlang version currently supported by
rebar3. Allows people to mix and match different versions of
the Erlang VM and rebar3 using multi-stage docker builds.

@ferd
Copy link
Collaborator

ferd commented Nov 5, 2020

Probably makes sense for us to have one that way.

I was wondering if it would also make sense to go for something as in https://adoptingerlang.org/docs/production/docker/ and push for a multi-stage build that handles releases as a template but I guess that's fully distinct from what we have here.

@lrascao
Copy link
Contributor Author

lrascao commented Nov 5, 2020

I suppose this PR is a step in that direction, i'm using those very same instructions at adoptingerlang.org and felt the need to pull down a specific rebar3 version.

For future reference purposes something like this:

# syntax = docker/dockerfile:experimental

# Pull down the desired rebar3 image version
FROM rebar3:latest as rebar3

FROM docker.pkg.github.com/adoptingerlang/service_discovery/erlang:22.1.1-alpine as builder

 # copy the rebar3 over from the rebar3 docker image and
 # overwriting the one being used by alpine
COPY --from=rebar3 /opt/.cache/rebar3 /opt/.cache/rebar3
COPY --from=rebar3 /usr/local/bin/rebar3 /usr/local/bin/rebar3

Dockerfile Outdated
COPY --from=builder /root/rebar3/_build/prod/bin/rebar3 .

# and install it
RUN install -v ./rebar3 /usr/local/bin/ \
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd prefer this used rebar3 local install. You can set HOME to /opt in the instruction and then create a link from /usr/local/bin/rebar3 to /opt/.cache/rebar3/bin/rebar3.

Patch I've been meaning to make is to have local install properly use XDG_CACHE_DIR and then you could set that to /opt/ and it'd install to /opt/rebar3/ instead of that .cache directory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

update the comment above. With these changes, you'll also need to copy over /opt/.cache/rebar3 besides the rebar3 binary, is this better somehow?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, didn't think about the use of copying it into another image. Argh, annoying, it is far better to use the unpacked version when calling from Entrypoint, so people default to that, but is a pain when copying.

I guess you can just undo my suggested change. It'd probably be confusing if there was both the rebar3 escript and the local install copy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If properly documented, people will copy/paste the two lines over to their own docker images. What is being offered through the local install method additionally to install -v?
btw, install -v is the method used in the official Erlang docker images

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yea, I want to change that in those too.

local install offers it not being an escript, which among making it slightly more efficient means the terminal doesn't get all screwed up if the user ctrl-c's out of the shell.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah nice, we should keep local install then

Based on the closest Alpine Erlang version currently supported by
rebar3. Allows people to mix and match different versions of
the Erlang VM and rebar3 using multi-stage builds.
@lrascao lrascao force-pushed the feature/dockerfile branch from ee178c0 to f228df2 Compare November 9, 2020 09:34
@lrascao lrascao requested a review from tsloughter November 9, 2020 09:35
@ferd ferd changed the title Add a docker recipe Add a docker recipe for rebar3 itself Nov 17, 2020
@ferd ferd merged commit 85f4a21 into erlang:master Nov 17, 2020
@lrascao lrascao deleted the feature/dockerfile branch November 18, 2020 09:11
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