diff --git a/Jenkinsfile b/Jenkinsfile index 32495ca..e8bf12d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -182,7 +182,7 @@ stage('Build CodeDeploy Archive') { node { unstash 'src' wrap.call({ - sh ("./codedeploy/bin/build.sh") + sh ("./bin/build-codedeploy.sh") }) } } diff --git a/codedeploy/bin/build.sh b/bin/build-codedeploy.sh similarity index 78% rename from codedeploy/bin/build.sh rename to bin/build-codedeploy.sh index e61b0de..126fe6c 100755 --- a/codedeploy/bin/build.sh +++ b/bin/build-codedeploy.sh @@ -13,11 +13,9 @@ export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" BASE_DIR="$DIR/.." BUILD_DIR="$BASE_DIR/build" -ANSIBLE_DIR="$BASE_DIR/../ansible" -APPLICTION_DIR="$BASE_DIR/../application" -SRC_DIR="$BASE_DIR/../src" -VENV_DIR="$BASE_DIR/../venv" -DOCKER_DIR="$BASE_DIR/.." +ANSIBLE_DIR="$BASE_DIR/ansible" +APPLICTION_DIR="$BASE_DIR/application" +SRC_DIR="$BASE_DIR/src" GIT_REV="$(git rev-parse --short HEAD)" BUILD_NUMBER=${BUILD_NUMBER:-0} @@ -39,20 +37,22 @@ fi mkdir -p "$BUILD_DIR/socket" echo Build docker container $CONTAINERNAME -docker build -f=Dockerfile -t "$CONTAINERNAME" "$DOCKER_DIR" +docker build -f=Dockerfile -t "$CONTAINERNAME" "$BASE_DIR" echo Create python virtual environment -docker run --rm -v "$DOCKER_DIR:/src" "$CONTAINERNAME" /bin/bash -c \ - "mkdir -p /src/venv ; \ - cp -fa /app/venv/* /src/venv" +docker run \ + --rm \ + -v "$BASE_DIR:/src" \ + "$CONTAINERNAME" \ + /bin/bash -c \ + "mkdir -p /src/build/venv ; \ + cp -fa /app/venv/* /src/build/venv" SOURCES="$BASE_DIR/bin $ANSIBLE_DIR $APPLICTION_DIR $SRC_DIR -$BASE_DIR/appspec.yml -$BASE_DIR/bin -$VENV_DIR" +$BASE_DIR/codedeploy/appspec.yml" for src in $SOURCES; do cp -a "$src" "$BUILD_DIR" done @@ -70,7 +70,7 @@ done ) echo Remove docker generated files -docker run --rm -v "$DOCKER_DIR:/src" "$CONTAINERNAME" /bin/bash -c \ +docker run --rm -v "$BASE_DIR:/src" "$CONTAINERNAME" /bin/bash -c \ "rm -rf /src/venv" cd "$BUILD_DIR" diff --git a/codedeploy/bin/AfterInstall.sh b/bin/codedeploy/AfterInstall.sh similarity index 100% rename from codedeploy/bin/AfterInstall.sh rename to bin/codedeploy/AfterInstall.sh diff --git a/codedeploy/bin/ApplicationStart.sh b/bin/codedeploy/ApplicationStart.sh similarity index 100% rename from codedeploy/bin/ApplicationStart.sh rename to bin/codedeploy/ApplicationStart.sh diff --git a/codedeploy/bin/ApplicationStop.sh b/bin/codedeploy/ApplicationStop.sh similarity index 100% rename from codedeploy/bin/ApplicationStop.sh rename to bin/codedeploy/ApplicationStop.sh diff --git a/codedeploy/bin/BeforeInstall.sh b/bin/codedeploy/BeforeInstall.sh similarity index 100% rename from codedeploy/bin/BeforeInstall.sh rename to bin/codedeploy/BeforeInstall.sh diff --git a/codedeploy/bin/ValidateService.sh b/bin/codedeploy/ValidateService.sh similarity index 100% rename from codedeploy/bin/ValidateService.sh rename to bin/codedeploy/ValidateService.sh diff --git a/codedeploy/appspec.yml b/codedeploy/appspec.yml index 2538144..6c7275f 100644 --- a/codedeploy/appspec.yml +++ b/codedeploy/appspec.yml @@ -12,17 +12,17 @@ files: destination: /app/ansible hooks: ApplicationStop: - - location: bin/ApplicationStop.sh + - location: bin/codedeploy/ApplicationStop.sh timeout: 600 BeforeInstall: - - location: bin/BeforeInstall.sh + - location: bin/codedeploy/BeforeInstall.sh timeout: 30 AfterInstall: - - location: bin/AfterInstall.sh + - location: bin/codedeploy/AfterInstall.sh timeout: 300 ApplicationStart: - - location: bin/ApplicationStart.sh + - location: bin/codedeploy/ApplicationStart.sh timeout: 120 ValidateService: - - location: bin/ValidateService.sh + - location: bin/codedeploy/ValidateService.sh timeout: 60