Skip to content

Commit

Permalink
Update docker images to use composer user for npm installs and (hyper…
Browse files Browse the repository at this point in the history
…ledger-archives#2726)

wrap composer command in the composer-cli image

Contributes to #2673

Signed-off-by: James Taylor <[email protected]>
  • Loading branch information
jt-nti authored and nklincoln committed Nov 15, 2017
1 parent 0cfc6ba commit 440eb76
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 31 deletions.
24 changes: 13 additions & 11 deletions packages/composer-cli/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,25 @@ ENV NPM_CONFIG_LOGLEVEL warn
ARG VERSION=latest

# Need to install extra dependencies for native modules.
RUN apk add --no-cache make gcc g++ python git libc6-compat && \
npm install --unsafe-perm --production -g composer-cli@${VERSION} && \
npm cache clean --force && \
RUN deluser --remove-home node && \
addgroup -g 1000 composer && \
adduser -u 1000 -G composer -s /bin/sh -D composer && \
apk add --no-cache make gcc g++ python git libc6-compat && \
su -c 'npm config set prefix ''/home/composer/.npm-global''' - composer && \
su -c 'npm install --production -g composer-cli@${VERSION}' - composer && \
su -c 'npm cache clean --force' - composer && \
rm -rf /home/composer/.config /home/composer/.node-gyp /home/composer/.npm && \
apk del make gcc g++ python git

# Remove yarn
RUN rm -r /opt/yarn && \
rm /usr/local/bin/yarn /usr/local/bin/yarnpkg

# Create the composer user ID.
RUN adduser -S composer

# Run as the composer user ID.
USER composer

# Add global composer modules to the path.
ENV PATH /home/composer/.npm-global/bin:$PATH

# Run in the composer users home directory.
WORKDIR /home/composer

# Run the composer CLI.
CMD ["composer"]
ENTRYPOINT ["composer"]
CMD ["--help"]
21 changes: 11 additions & 10 deletions packages/composer-playground/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@ ENV NPM_CONFIG_LOGLEVEL warn
ARG VERSION=latest

# Need to install extra dependencies for native modules.
RUN apk add --no-cache make gcc g++ python git libc6-compat && \
npm install --unsafe-perm --production -g pm2 composer-playground@${VERSION} && \
npm cache clean --force && \
RUN deluser --remove-home node && \
addgroup -g 1000 composer && \
adduser -u 1000 -G composer -s /bin/sh -D composer && \
apk add --no-cache make gcc g++ python git libc6-compat && \
su -c 'npm config set prefix ''/home/composer/.npm-global''' - composer && \
su -c 'npm install --production -g pm2 composer-playground@${VERSION}' - composer && \
su -c 'npm cache clean --force' - composer && \
rm -rf /home/composer/.config /home/composer/.node-gyp /home/composer/.npm && \
apk del make gcc g++ python git

# Remove yarn
RUN rm -r /opt/yarn && \
rm /usr/local/bin/yarn /usr/local/bin/yarnpkg

# Create the composer user ID.
RUN adduser -S composer

# Run as the composer user ID.
USER composer

# Add global composer modules to the path.
ENV PATH /home/composer/.npm-global/bin:$PATH

# Run in the composer users home directory.
WORKDIR /home/composer

Expand Down
21 changes: 11 additions & 10 deletions packages/composer-rest-server/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@ ENV NPM_CONFIG_LOGLEVEL warn
ARG VERSION=latest

# Need to install extra dependencies for native modules.
RUN apk add --no-cache make gcc g++ python git libc6-compat && \
npm install --unsafe-perm --production -g pm2 composer-rest-server@${VERSION} && \
npm cache clean --force && \
RUN deluser --remove-home node && \
addgroup -g 1000 composer && \
adduser -u 1000 -G composer -s /bin/sh -D composer && \
apk add --no-cache make gcc g++ python git libc6-compat && \
su -c 'npm config set prefix ''/home/composer/.npm-global''' - composer && \
su -c 'npm install --production -g pm2 composer-rest-server@${VERSION}' - composer && \
su -c 'npm cache clean --force' - composer && \
rm -rf /home/composer/.config /home/composer/.node-gyp /home/composer/.npm && \
apk del make gcc g++ python git

# Remove yarn
RUN rm -r /opt/yarn && \
rm /usr/local/bin/yarn /usr/local/bin/yarnpkg

# Create the composer user ID.
RUN adduser -S composer

# Run as the composer user ID.
USER composer

# Add global composer modules to the path.
ENV PATH /home/composer/.npm-global/bin:$PATH

# Run in the composer users home directory.
WORKDIR /home/composer

Expand Down

0 comments on commit 440eb76

Please sign in to comment.