1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-06 03:50:04 +02:00

Merge branch 'shrink-docker-image'

This commit is contained in:
Simo Kinnunen 2015-08-24 17:29:03 +09:00
commit 95860fd78f
2 changed files with 27 additions and 17 deletions

View file

@ -2,6 +2,7 @@
.DS_Store
/*.tgz
/.bowerrc
/.dockerignore
/.editorconfig
/.env
/.gitignore
@ -9,11 +10,12 @@
/.jscsrc
/.npmignore
/.npmrc
/.travis.yml
/docker
/Dockerfile
/bower.json
/component.json
/gulpfile.js
/node_modules/
/npm-debug.log
/res/bower_components/
/res/test/

View file

@ -1,11 +1,4 @@
FROM openstf/base:v1.0.1
# Add a user for the app.
RUN useradd --system \
--no-create-home \
--shell /usr/sbin/nologin \
--home-dir /app \
stf
FROM openstf/base:v1.0.2
# Sneak the stf executable into $PATH.
ENV PATH /app/bin:$PATH
@ -18,16 +11,31 @@ WORKDIR /app
EXPOSE 3000
# Copy app source.
COPY . /app/
COPY . /tmp/build/
# Get the rest of the dependencies and build.
RUN export PATH=/app/node_modules/.bin:$PATH && \
npm install && \
bower install --allow-root && \
gulp build && \
npm prune --production
# Give permissions to our build user.
RUN mkdir -p /app && \
chown -R stf-build:stf-build /tmp/build /app
# Switch to weak user.
# Switch over to the build user.
USER stf-build
# Run the build.
RUN set -x && \
cd /tmp/build && \
export PATH=$PWD/node_modules/.bin:$PATH && \
npm install --loglevel http && \
npm pack && \
tar xzf stf-*.tgz --strip-components 1 -C /app && \
bower cache clean && \
npm prune --production && \
mv node_modules /app && \
npm cache clean && \
rm -rf ~/.node-gyp && \
cd /app && \
rm -rf /tmp/*
# Switch to the app user.
USER stf
# Show help by default.