5 ms·
One additional tip for readability is to replace the && with set -e at the top of any RUN commands that combine more than one command. before: RUN curl -SLO
by 23david 12y ago
One additional tip for readability is to replace the && with set -e at the top of any RUN commands that combine more than one command.
before:
RUN curl -SLO "http://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.gz" \
&& tar -xzf "node-v$NODE_VERSION-linux-x64.tar.gz" -C /usr/local --strip-components=1 \
&& rm "node-v$NODE_VERSION-linux-x64.tar.gz"
after:
RUN set -e; \
curl -SLO "http://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.gz"; \
tar -xzf "node-v$NODE_VERSION-linux-x64.tar.gz" -C /usr/local --strip-components=1; \
rm "node-v$NODE_VERSION-linux-x64.tar.gz
- digisign 12y agoHmm, needs additional semi-colons.
- 23david 12y agowhere? I was trying to use the example given... Here's another, smaller example: # install wget without artifacts RUN set -e; \ apt-get update; \ apt-get install -y wget; \ apt-get clean; \ rm -rf /var/lib/apt/lists/*
- e12e 12y agoI think parent meant you trade two &&s for one ;. Personally I also don't think the meaning is as clear, and you now need to maintain the top line if you cut'n'paste. I suppose it's a matter of taste.
- mnarayan01 12y agoWhy?
- masklinn 12y agoBecause it's more readable? It tells you at the top that any failure will fail the whole thing, and you can avoid the prefix `&&` which reduces the effective indentation level and noise.
- mnarayan01 12y agoYou can use the same spacing for the ampersands as used for the semicolons (i.e. at the end of the line). That said, obviously there's going to be different preferences...I was more wondering if there was some semantic difference.
- masklinn 12y ago> You can use the same spacing for the ampersands as used for the semicolons (i.e. at the end of the line). Then if the lines are long (as they are here) they get cut off and it's much harder to notice that they're there at all.