Commit 3030a66c authored by Administrator's avatar Administrator

Update .gitlab-ci.yml

parent 76c5e7f7
Pipeline #56 failed with stages
in 26 seconds
image: docker:latest
services:
- docker:dind
cache:
paths:
- .m2/
variables:
REPOSITORY_URL: 751503455312.dkr.ecr.us-west-2.amazonaws.com/altimetrik-ecs
REGION: us-west-2
TASK_DEFINTION_NAME: first-run-task-definition
CLUSTER_NAME: playground-ecs
SERVICE_NAME: Test
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- apk add --no-cache curl jq python py-pip
- pip install awscli
- $(aws ecr get-login --no-include-email --region "${REGION}")
- IMAGE_TAG="$(echo $CI_COMMIT_SHA | head -c 8)"
stages:
- build
- deploy
build:
stage: build
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE" .
- docker tag docker:latest "$CI_REGISTRY_IMAGE/$CI_PROJECT_NAME:latest"
- docker push "$CI_REGISTRY_IMAGE/$CI_PROJECT_NAME:latest"
#sonar:
# stage: test
# script:
# - mvn --batch-mode verify sonar:sonar -Dsonar.exclusions="pom.xml" -Dsonar.host.url=$SONAR_URL -Dsonar.login=$SONAR_LOGIN
- echo "Building image..."
- docker build -t $REPOSITORY_URL:latest .
- echo "Tagging image..."
- docker tag $REPOSITORY_URL:latest $REPOSITORY_URL:$IMAGE_TAG
- echo "Pushing image..."
- docker push $REPOSITORY_URL:latest
- docker push $REPOSITORY_URL:$IMAGE_TAG
only:
- master
deploy:
stage: deploy
script:
- docker pull "$CI_REGISTRY_IMAGE/$CI_PROJECT_NAME:latest"
- docker run -d "$CI_REGISTRY_IMAGE/$CI_PROJECT_NAME:latest"
- echo $REPOSITORY_URL:$IMAGE_TAG
- TASK_DEFINITION=$(aws ecs describe-task-definition --task-definition "$TASK_DEFINTION_NAME" --region "${REGION}")
- NEW_CONTAINER_DEFINTIION=$(echo $TASK_DEFINITION | python $CI_PROJECT_DIR/update_task_definition_image.py $REPOSITORY_URL:$IMAGE_TAG)
- echo "Registering new container definition..."
- aws ecs register-task-definition --region "${REGION}" --family "${TASK_DEFINTION_NAME}" --container-definitions "${NEW_CONTAINER_DEFINTIION}"
- echo "Updating the service..."
- aws ecs update-service --region "${REGION}" --cluster "${CLUSTER_NAME}" --service "${SERVICE_NAME}" --task-definition "${TASK_DEFINTION_NAME}"
only:
- master
- master
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment