Commit 6f51f033 authored by Miguel Angel Reina Ortega's avatar Miguel Angel Reina Ortega
Browse files

Adding gitlab-ci yaml file for automatic deployment

parent 2bb5c756
Loading
Loading
Loading
Loading
Loading

.gitlab-ci.yml

0 → 100644
+19 −0
Original line number Diff line number Diff line
# CI/CD:
#
# BUILD triggered by:
#  - branches
#  
#   

Build tosca-ie docker image:
  stage: build
  before_script: 
    - cp ./env_example env
  script: 
    - ./relaunch.sh $CI_COMMIT_BRANCH
  rules:
    - if: $CI_COMMIT_BRANCH
      changes:
        - Dockerfile
        - src/*
        - requirements.txt 
 No newline at end of file
+4 −4
Original line number Diff line number Diff line
@@ -11,13 +11,13 @@ if [ "$CNT" != "" ] ; then
    docker stop "$CNT"
fi

if [ "$1" == "stop" ] ; then
if [ "$2" == "stop" ] ; then
    exit 0
fi 

sed -i -E "s/(LAST_COMMIT=).+/\1$(git log -n 1 --oneline)/" env
sed -i -E "s/(LAST_COMMIT=).+/\1$(git rev-parse HEAD)/" env

docker build -t tosca-ie-sample:latest .
docker build -t tosca-ie-sample:$1 .

docker run -d --restart unless-stopped -t -p 5000:5000 --env-file ./env tosca-ie-sample
docker run -d --restart unless-stopped -t -p 5000:5000 --env-file ./env tosca-ie-sample:$1