Skip to content

Refactor RUN bash -xec to just use RUN#14

Closed
maxnordlund wants to merge 2 commits intodocker-library:masterfrom
maxnordlund:patch-1
Closed

Refactor RUN bash -xec to just use RUN#14
maxnordlund wants to merge 2 commits intodocker-library:masterfrom
maxnordlund:patch-1

Conversation

@maxnordlund
Copy link
Copy Markdown

This changes the cd /usr/src/go/src to use WORKDIR and -x flag to || exit $?. I've tried this change on my machine, and it seams fine. Fair warning the log is ~7600 lines long.

This changes the `cd /usr/src/go/src` to use `WORKDIR` and `-x` flag to `|| exit $?`.
@yosifkit
Copy link
Copy Markdown
Member

yosifkit commented Oct 1, 2014

Is there a problem that this is solving? The current bash -xec gives nice log output when building.

@maxnordlund
Copy link
Copy Markdown
Author

I didn't notice a big difference when I tested, but for me it feels like a hack, a way around the Dockerfile format. For example the use of cd instead of WORKDIR. Since this is an official language repo I thought it would be nice to show how it's supposed to be done, on the other hand both approaches do work and why change something that isn't broken?

@yosifkit
Copy link
Copy Markdown
Member

yosifkit commented Oct 2, 2014

Using WORKDIR would be nice to do if we had multiple RUN lines that needed it and wanted to leave it for users of the image. In this case we would need a second WORKDIR to reset it after we finish with the RUN, so we would just be adding layers.

@maxnordlund
Copy link
Copy Markdown
Author

I hadn't thought about the extra layers. So I removed the WORKDIR, and currently it removes the bash -xec '...'. This makes it easier to read IMHO, but will still bail if something goes wrong using || exit $?.

@tianon
Copy link
Copy Markdown
Member

tianon commented Oct 2, 2014

Ok, that's fair, but how about this, so the spirit of the original is kept?

RUN set -ex; \
    cd /usr/src/go/src; \
    for platform in $GOLANG_CROSSPLATFORMS; do \
        GOOS=${platform%/*} \
        GOARCH=${platform##*/} \
        ./make.bash --no-clean 2>&1; \
    done

The set -ex will both make it so that the entire thing exits nonzero if one command does, and will also print out each command as it's executed (which is really nice for giving us progress of which platform we're currently building for, since it takes a really long time to build them all).

@tianon tianon mentioned this pull request Nov 15, 2014
@tianon tianon closed this in #25 Nov 17, 2014
@maxnordlund maxnordlund deleted the patch-1 branch November 17, 2014 22:46
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