diff --git a/appspec.yaml b/appspec.yaml new file mode 100644 index 0000000..5820d93 --- /dev/null +++ b/appspec.yaml @@ -0,0 +1,9 @@ +version: 0.0 +Resources: + - TargetService: + Type: AWS::ECS::Service + Properties: + TaskDefinition: + LoadBalancerInfo: + ContainerName: "29-conteiner" + ContainerPort: 9080 diff --git a/buildspec.yml b/buildspec.yml new file mode 100644 index 0000000..f526814 --- /dev/null +++ b/buildspec.yml @@ -0,0 +1,50 @@ +version: 0.2 + +env: + variables: + AWS_ACCOUNT_ID: "452911533244" + CLUSTER: "poc" + SERVICE: "poc-service" + IMAGE_REPO_NAME: "myapp" + IMAGE_TAG: "v1.0.0" + AWS_DEFAULT_REGION: "us-west-2" + +phases: + install: + commands: + - echo Entered the install phase... + - wget https://download.java.net/java/GA/jdk13.0.1/cec27d702aa74d5a8630c65ae61e4305/9/GPL/openjdk-13.0.1_linux-x64_bin.tar.gz + - tar -xvf openjdk-13.0.1_linux-x64_bin.tar.gz + - mv jdk-13.0.1 /opt/ + - JAVA_HOME='/opt/jdk-13.0.1' + - PATH="$JAVA_HOME/bin:$PATH" + - export PATH + - echo java termina install + - wget https://mirrors.estointernet.in/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz + - tar -xvf apache-maven-3.6.3-bin.tar.gz + - mv apache-maven-3.6.3 /opt/ + - M2_HOME='/opt/apache-maven-3.6.3' + - PATH="$M2_HOME/bin:$PATH" + - export PATH + finally: + - echo This always runs even if the update or install command fails + pre_build: + commands: + - echo Ingresando a AWS ECR... + - aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com + + build: + commands: + - echo Maven empezar clean and install + - mvn clean + - mvn install + - echo Creando imagen Docker + - docker build -t myapp:v1.0.0 . + - docker tag $IMAGE_REPO_NAME:$IMAGE_TAG $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG + - echo Copiando imagen de Docker a repositorio... + - docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG + + post_build: + commands: + - echo actualizando servicio fargate... + - aws ecs update-service --cluster $CLUSTER --service $SERVICE --force-new-deployment diff --git a/src/main/webapp/index.html b/src/main/webapp/index.html index 347e9cc..d69f5e8 100755 --- a/src/main/webapp/index.html +++ b/src/main/webapp/index.html @@ -27,7 +27,7 @@ $( document ).ready(function() { $.i18n().load( { en: { - "welcome": "Welcome.", + "welcome": "Welcome PoC.", "name": "name", "what_is_your_name": "What is your name?", "hello": "Hello $1", diff --git a/taskdef.json b/taskdef.json new file mode 100644 index 0000000..5621313 --- /dev/null +++ b/taskdef.json @@ -0,0 +1,28 @@ +{ + "executionRoleArn": "arn:aws:iam::452911533244:role/ecsTaskExecutionRole", + "containerDefinitions": [ + { + "portMappings": [ + { + "hostPort": 9080, + "protocol": "tcp", + "containerPort": 9080 + } + ], + "image": "452911533244.dkr.ecr.us-west-2.amazonaws.com/myapp:v1.0.0", + "essential": true, + "name": "29-conteiner" + } + ], + "memory": "512", + "compatibilities": [ + "EC2", + "FARGATE" + ], + "family": "first-run-task-definition", + "requiresCompatibilities": [ + "FARGATE" + ], + "networkMode": "awsvpc", + "cpu": "256" +}