Skip to content

Commit

Permalink
Rework Travis build step to build production image entirely with Dock…
Browse files Browse the repository at this point in the history
…er and deploy to wowanalyzer/wowanalyzer instead of martijnhols/wowanalyzer
  • Loading branch information
MartijnHols committed Oct 13, 2018
1 parent 1a0f0d1 commit 0531c3f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 22 deletions.
7 changes: 3 additions & 4 deletions .travis/deploy.sh → .docker/production/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export REPO=martijnhols/wowanalyzer;
export REPO=wowanalyzer/wowanalyzer;
export BUILD_TAG="build-$TRAVIS_BUILD_NUMBER";
export DEPLOY_TAG=$(
if [ "$TRAVIS_BRANCH" == "master" ]; then
Expand All @@ -10,9 +10,8 @@ export DEPLOY_TAG=$(

echo "> Create a Docker image for this specific build. This allows us to go back to a particular build at any time, and makes it possible to deploy without rebuilding by just re-tagging the image.";

docker build --tag $REPO:$BUILD_TAG --file Dockerfile.package .;
echo "> Push Docker image";
docker login --username="$DOCKER_USERNAME" --password="$DOCKER_PASSWORD";
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
docker tag wowanalyzer $REPO:$DEPLOY_TAG;
docker push $REPO:$BUILD_TAG;
docker tag $REPO:$BUILD_TAG $REPO:$DEPLOY_TAG;
docker push $REPO:$DEPLOY_TAG;
9 changes: 8 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# This greatly speeds up the build process if the user already has run `npm install` locally
node_modules
node_modules/
build/
server/build/
server/node_modules/

# Unused files
.docker/
.docker*
.travis/
.travis.yml
Docker*
*.md
# .git is very slow and we don't need it for anything but `npm test`
Expand Down
19 changes: 2 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,12 @@ jobs:
directories:
- node_modules
- server/node_modules
install:
- npm install --dev
- cd server && npm install --dev && cd ..
script:
- echo "> Build server"
- cd server
- npm run build
- echo "> The server has already been built so we no longer need the devDependencies (reduces the final bundle size)"
- npm prune --production
- cd ..
- if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo "> Disabling sourcemap generation to save build time, this is a PR so won't be deployed anyway.";
export GENERATE_SOURCEMAP=false;
fi
- echo "> Build app"
- npm run build
script: docker build -f .docker/production/Dockerfile --tag wowanalyzer .
# Reminder: deploy doesn't run on PRs
deploy:
provider: script
skip_cleanup: true
script: bash .travis/deploy.sh
script: bash .docker/production/deploy.sh
on:
all_branches: true
after_failure:
Expand Down

0 comments on commit 0531c3f

Please sign in to comment.