try updating travis to have deploy script
This commit is contained in:
parent
d44027c58e
commit
16b54b89ca
4 changed files with 61 additions and 96 deletions
57
.travis.yml
57
.travis.yml
|
@ -3,31 +3,40 @@ language: node_js
|
|||
node_js:
|
||||
- "8.11.1"
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- "$HOME/google-cloud-sdk/"
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
stages:
|
||||
- test
|
||||
- build
|
||||
before_install:
|
||||
- docker-compose -f docker-compose-development.yml up -d
|
||||
- docker ps -a
|
||||
|
||||
jobs:
|
||||
include:
|
||||
- stage: test
|
||||
before_install:
|
||||
- docker-compose -f docker-compose-development.yml up -d
|
||||
- docker ps -a
|
||||
install: true
|
||||
script:
|
||||
# Run unit tests in the app container
|
||||
- docker-compose exec -T app npm run test --verbose
|
||||
- stage: build
|
||||
if: branch = master OR branch = production-docker
|
||||
env:
|
||||
- APP_IMAGE_NAME=p5jswebeditor_app
|
||||
script:
|
||||
- docker-compose stop
|
||||
- docker-compose build --no-cache
|
||||
- docker image ls
|
||||
- docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
|
||||
- docker tag $APP_IMAGE_NAME $DOCKER_USERNAME/$DOCKER_REPOSITORY:latest
|
||||
- docker push $DOCKER_USERNAME/$DOCKER_REPOSITORY:latest
|
||||
install: true
|
||||
|
||||
script:
|
||||
- docker-compose exec -T app npm run test --verbose
|
||||
|
||||
after_success:
|
||||
- docker-compose stop
|
||||
|
||||
before_deploy:
|
||||
- if [ ! -d "$HOME/google-cloud-sdk/bin" ]; then rm -rf $HOME/google-cloud-sdk; export CLOUDSDK_CORE_DISABLE_PROMPTS=1; curl https://sdk.cloud.google.com | bash; fi
|
||||
- source /home/travis/google-cloud-sdk/path.bash.inc
|
||||
- gcloud --quiet version
|
||||
- gcloud --quiet components update
|
||||
- gcloud --quiet components beta update
|
||||
- gcloud --quiet components update kubectl
|
||||
|
||||
deploy:
|
||||
- provider: script
|
||||
script: bash deploy.sh
|
||||
skip_cleanup: true
|
||||
on:
|
||||
branch: master OR production-docker
|
||||
|
||||
env:
|
||||
global:
|
||||
- APP_IMAGE_NAME=p5jswebeditor_app
|
||||
|
|
28
deploy.sh
Normal file
28
deploy.sh
Normal file
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
docker-compose build --no-cache
|
||||
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
|
||||
docker tag $APP_IMAGE_NAME $DOCKER_USERNAME/$DOCKER_REPOSITORY:$TRAVIS_COMMIT
|
||||
docker push $DOCKER_USERNAME/$DOCKER_REPOSITORY:$TRAVIS_COMMIT
|
||||
|
||||
# echo $GCLOUD_SERVICE_KEY_PRD | base64 --decode -i > ${HOME}/gcloud-service-key.json
|
||||
# gcloud auth activate-service-account --key-file ${HOME}/gcloud-service-key.json
|
||||
|
||||
# gcloud --quiet config set project $PROJECT_NAME_PRD
|
||||
# gcloud --quiet config set container/cluster $CLUSTER_NAME_PRD
|
||||
# gcloud --quiet config set compute/zone ${CLOUDSDK_COMPUTE_ZONE}
|
||||
# gcloud --quiet container clusters get-credentials $CLUSTER_NAME_PRD
|
||||
|
||||
# gcloud docker push gcr.io/${PROJECT_NAME_PRD}/${DOCKER_IMAGE_NAME}
|
||||
|
||||
# yes | gcloud beta container images add-tag gcr.io/${PROJECT_NAME_PRD}/${DOCKER_IMAGE_NAME}:$TRAVIS_COMMIT gcr.io/${PROJECT_NAME_PRD}/${DOCKER_IMAGE_NAME}:latest
|
||||
|
||||
# kubectl config view
|
||||
# kubectl config current-context
|
||||
|
||||
# kubectl set image deployment/${KUBE_DEPLOYMENT_NAME} ${KUBE_DEPLOYMENT_CONTAINER_NAME}=gcr.io/${PROJECT_NAME_PRD}/${DOCKER_IMAGE_NAME}:$TRAVIS_COMMIT
|
||||
|
||||
# sleep 30
|
||||
# npm run e2e_test
|
|
@ -18,16 +18,6 @@ services:
|
|||
- MONGO_INITDB_DATABASE
|
||||
- MONGO_RW_USERNAME
|
||||
- MONGO_RW_PASSWORD
|
||||
nginx:
|
||||
image: nginx:1.13
|
||||
volumes:
|
||||
- "$PWD/nginx/alpha.editor.p5js.org.conf:/etc/nginx/conf.d/default.conf"
|
||||
ports:
|
||||
- '80:80'
|
||||
depends_on:
|
||||
- app
|
||||
links:
|
||||
- app
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
|
@ -73,7 +63,6 @@ services:
|
|||
- /opt/node/app/node_modules
|
||||
ports:
|
||||
- '8000:8000'
|
||||
# - '443:443'
|
||||
depends_on:
|
||||
- mongo
|
||||
volumes:
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
# HTTP - redirect all requests to HTTPS:
|
||||
server {
|
||||
listen 80;
|
||||
#server_name alpha.editor.p5js.org;
|
||||
location / {
|
||||
proxy_pass http://app:8000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
}
|
||||
# location ~* \/login(\/)* {
|
||||
# return 301 https://$host$request_uri;
|
||||
# }
|
||||
# location ~* \/signup(\/)* {
|
||||
# return 301 https://$host$request_uri;
|
||||
# }
|
||||
# location ~* \/reset-password(\/)* {
|
||||
# return 301 https://$host$request_uri;
|
||||
# }
|
||||
# location ~* "\/[a-zA-Z0-9._-]{1,20}\/account(\/)*" {
|
||||
# return 301 https://$host$request_uri;
|
||||
# }
|
||||
|
||||
}
|
||||
|
||||
# server {
|
||||
# listen 443;
|
||||
# ssl on;
|
||||
# ssl_certificate /etc/letsencrypt/live/alpha.editor.p5js.org/fullchain.pem;
|
||||
# ssl_certificate_key /etc/letsencrypt/live/alpha.editor.p5js.org/privkey.pem;
|
||||
# server_name alpha.editor.p5js.org;
|
||||
# location / {
|
||||
# proxy_pass http://127.0.0.1:8000;
|
||||
# proxy_http_version 1.1;
|
||||
# proxy_set_header Upgrade $http_upgrade;
|
||||
# proxy_set_header Connection 'upgrade';
|
||||
# proxy_set_header Host $host;
|
||||
# proxy_cache_bypass $http_upgrade;
|
||||
# }
|
||||
# }
|
||||
|
||||
# server {
|
||||
# listen 80;
|
||||
# server_name editor.p5js.org;
|
||||
# location ~ ^/(.*) {
|
||||
# return 302 http://alpha.editor.p5js.org/$1;
|
||||
# }
|
||||
# }
|
||||
|
||||
# server {
|
||||
# listen 443;
|
||||
# ssl on;
|
||||
# ssl_certificate /etc/letsencrypt/live/editor.p5js.org/fullchain.pem;
|
||||
# ssl_certificate_key /etc/letsencrypt/live/editor.p5js.org/privkey.pem;
|
||||
# server_name editor.p5js.org;
|
||||
# location ~ ^/(.*) {
|
||||
# return 302 https://alpha.editor.p5js.org/$1;
|
||||
# }
|
||||
# }
|
Loading…
Reference in a new issue