...
 
Commits (2)
# This file is a template, and might need editing before it works on your project.
# Official framework image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/node/tags/
image: node:latest
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
stages:
- build
- deploy
# This folder is cached between builds
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
cache:
paths:
- node_modules/
install_dependencies:
stage: build
script:
- npm install
artifacts:
paths:
- node_modules/
deploy:prod:
stage: deploy
script:
- bash deploy/deploy.sh
only:
- master
#!/bin/bash
# any future command that fails will exit the script
set -e
# Lets write the public key of our aws instance
eval $(ssh-agent -s)
echo "$PRIVATE_KEY_AWS" | tr -d '\r' | ssh-add - > /dev/null
# ** Alternative approach
# echo -e "$PRIVATE_KEY" > /root/.ssh/id_rsa
# chmod 600 /root/.ssh/id_rsa
# ** End of alternative approach
# disable the host key checking.
set -e
mkdir -p ~/.ssh
touch ~/.ssh/config
echo -e "Host *\n\tStrictHostKeyChecking no\n\n" >> ~/.ssh/config
# we have already setup the DEPLOYER_SERVER in our gitlab settings which is a
# comma seperated values of ip addresses.
DEPLOY_SERVERS=$DEPLOY_SERVERS
# lets split this string and convert this into array
# In UNIX, we can use this commond to do this
# ${string//substring/replacement}
# our substring is "," and we replace it with nothing.
ALL_SERVERS=(${DEPLOY_SERVERS//,/ })
echo "ALL_SERVERS ${ALL_SERVERS}"
# Lets iterate over this array and ssh into each EC2 instance
# Once inside.
# 1. Stop the server
# 2. Take a pull
# 3. Start the server
for server in "${ALL_SERVERS[@]}"
do
echo "deploying to ${server}"
ssh ubuntu@${server} 'bash -s' < ./deploy/updateAndRestart.sh
done
#!/bin/bash
# any future command that fails will exit the script
set -e
# Delete the old repo
rm -rf /home/ubuntu/rtlsfrontend/
# Install dependencies if they are missing
which git || (sudo apt-get update -yq --fix-missing && sudo apt-get install -yq git-core)
which npm || (sudo apt-get update -yq --fix-missing && sudo apt-get install -yq npm)
which nvm || (sudo npm install nvm -g)
which pm2 || (sudo npm install pm2 -g)
# clone the repo again
git clone https://gitlab.codecentric.de/RWTH_RTLS_BC/rtls_frontend.git
# stop the previous pm2
pm2 kill
# starting pm2 daemon
pm2 status
cd /home/ubuntu/rtlsfrontend
#install npm packages
echo "Running npm install"
npm install
#Restart the node server
npm start
......@@ -11,7 +11,8 @@
"e2e": "node test/e2e/runner.js",
"test": "npm run unit && npm run e2e",
"lint": "eslint --ext .js,.vue src test/unit test/e2e/specs",
"build": "node build/build.js"
"build": "node build/build.js",
"build:production": "NODE_ENV=production webpack --config webpack.config.js"
},
"dependencies": {
"bootstrap-vue": "^2.0.0-rc.11",
......
......@@ -98,6 +98,7 @@
<script>
import axios from 'axios';
let host = 'https://shrouded-tundra-25303.herokuapp.com/'
export default {
name: 'rtlsfrontend',
data() {
......@@ -118,7 +119,7 @@
methods: {
async onSubmitSaveData(evt) {
evt.preventDefault();
await axios.post('http://localhost:3000', {
await axios.post(host, {
headers: {
'Content-Type': 'application/json'
},
......@@ -144,7 +145,7 @@
async onSubmitTxID(evt) {
evt.preventDefault();
var self = this;
await axios.post('http://localhost:3000/verify', {
await axios.post(host + 'verify', {
headers: {
'Content-Type': 'application/json'
},
......