Skip to content

Commit

Permalink
Ajout Dockerfile & publication sur Docker hub
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas-C committed Mar 29, 2019
1 parent 8a4b803 commit b634351
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 37 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.git/
/node_modules/
/src/app/bower_components/
/Dockerfile
33 changes: 22 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,26 @@ node_js:
addons:
firefox: "50.0"

before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- npm install -g bower karma grunt-cli jshint
- npm start > /dev/null &
#- node node_modules/protractor/bin/webdriver-manager update
#- java -jar node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-*.jar -Dwebdriver.chrome.driver=./protractor/node_modules/webdriver-manager/selenium/chromedriver_2.25 &
- sleep 3 # give server time to start
stages:
- name: test
- name: docker
if: (branch = develop OR branch =~ ^v[0-9]) AND type != pull_request AND repo = "voyages-sncf-technologies/hesperides"

script:
- node_modules/.bin/karma start karma.conf.js --no-auto-watch --single-run
#- node_modules/.bin/protractor test/protractor-conf.js --browser=firefox
jobs:
include:
- stage: test
env: KARMA TESTS
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- npm install -g bower karma grunt-cli jshint
- npm start > /dev/null &
#- node node_modules/protractor/bin/webdriver-manager update
#- java -jar node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-*.jar -Dwebdriver.chrome.driver=./protractor/node_modules/webdriver-manager/selenium/chromedriver_2.25 &
- sleep 3 # give server time to start
script:
- node_modules/.bin/karma start karma.conf.js --no-auto-watch --single-run
#- node_modules/.bin/protractor test/protractor-conf.js --browser=firefox
- stage: docker
env: DEPLOY TO DOCKER HUB
script: "./.travis/docker_build_push.sh"
14 changes: 14 additions & 0 deletions .travis/docker_build_push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

set -o pipefail -o errexit -o nounset

# Build a docker image and push it to docker hub (only when it's not a pull request)
if [ "$DOCKER_USER" != "" ] && [ "$DOCKER_PASS" != "" ]; then
docker login -u $DOCKER_USER -p $DOCKER_PASS
export TAG=`if [ "$TRAVIS_BRANCH" == "master" ]; then echo "latest"; else echo $TRAVIS_BRANCH | sed -e 's/\//_/g' -e 's/\#//g' -e 's/\-/_/g' ; fi`
docker build -t hesperides/hesperides-gui:$TAG --label git_commit=$COMMIT .
docker push hesperides/hesperides-gui:$TAG
echo "✓ Docker image build and pushed to docker hub"
else
echo '✗ Missing $DOCKER_USER or $DOCKER_PASS environment variable'
fi
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:8-alpine
WORKDIR /usr/src/app
RUN echo '{"allow_root": true}' > /root/.bowerrc
RUN apk add git
COPY . .
RUN npm install
RUN npm run postinstall

FROM nginx:1.15-alpine
COPY --from=0 /usr/src/app/src/app /usr/share/nginx/html/
COPY --from=0 /usr/src/app/src/app/img/favicon.ico /usr/share/nginx/html/
25 changes: 0 additions & 25 deletions docker-compose.yml

This file was deleted.

3 changes: 2 additions & 1 deletion docs/start.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ <h2 class="section-title">Installation</h2>
<div id="install-docker" class="section-block">
<h3 class="block-title">Docker</h3>
<p><pre><code class="language-git">git pull https://github.com/voyages-sncf-technologies/hesperides-gui
docker-compose up</code></pre></p>
docker build -t hesperides-gui .
docker run --rm -it -p 80:80 hesperides-gui</code></pre></p>
</div><!--//section-block-->
<div id="install-sources" class="section-block">
<h3 class="block-title">Download sources</h3>
Expand Down

0 comments on commit b634351

Please sign in to comment.