diff --git a/.github/workflows/build_and_deploy_prd.yml b/.github/workflows/build_and_deploy_prd.yml index 44f15a6..fe8adbd 100644 --- a/.github/workflows/build_and_deploy_prd.yml +++ b/.github/workflows/build_and_deploy_prd.yml @@ -33,3 +33,5 @@ jobs: secrets: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + DOCKER_IMAGES_AWS_PULL_ACCESS_KEY_ID: ${{ secrets.DOCKER_IMAGES_AWS_PULL_ACCESS_KEY_ID }} + DOCKER_IMAGES_AWS_PULL_SECRET_ACCESS_KEY: ${{ secrets.DOCKER_IMAGES_AWS_PULL_SECRET_ACCESS_KEY }} diff --git a/.github/workflows/build_and_deploy_sdx.yml b/.github/workflows/build_and_deploy_sdx.yml index f66fd18..8809a08 100644 --- a/.github/workflows/build_and_deploy_sdx.yml +++ b/.github/workflows/build_and_deploy_sdx.yml @@ -33,3 +33,5 @@ jobs: secrets: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + DOCKER_IMAGES_AWS_PULL_ACCESS_KEY_ID: ${{ secrets.DOCKER_IMAGES_AWS_PULL_ACCESS_KEY_ID }} + DOCKER_IMAGES_AWS_PULL_SECRET_ACCESS_KEY: ${{ secrets.DOCKER_IMAGES_AWS_PULL_SECRET_ACCESS_KEY }} diff --git a/.github/workflows/build_and_deploy_stg.yml b/.github/workflows/build_and_deploy_stg.yml index 5ce8268..61b6da7 100644 --- a/.github/workflows/build_and_deploy_stg.yml +++ b/.github/workflows/build_and_deploy_stg.yml @@ -33,3 +33,5 @@ jobs: secrets: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + DOCKER_IMAGES_AWS_PULL_ACCESS_KEY_ID: ${{ secrets.DOCKER_IMAGES_AWS_PULL_ACCESS_KEY_ID }} + DOCKER_IMAGES_AWS_PULL_SECRET_ACCESS_KEY: ${{ secrets.DOCKER_IMAGES_AWS_PULL_SECRET_ACCESS_KEY }} diff --git a/.github/workflows/lint_tests_and_sonar.yml b/.github/workflows/lint_tests_and_sonar.yml index b25ba8b..5781086 100644 --- a/.github/workflows/lint_tests_and_sonar.yml +++ b/.github/workflows/lint_tests_and_sonar.yml @@ -37,11 +37,23 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Login to Docker Hub - uses: docker/login-action@v2 + - name: Instalar Docker Compose Standalone + run: | + sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + sudo chmod +x /usr/local/bin/docker-compose + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v3 + id: configure-ecr with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} + aws-access-key-id: ${{ secrets.DOCKER_IMAGES_AWS_PULL_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.DOCKER_IMAGES_AWS_PULL_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + mask-aws-account-id: "no" + + - name: Login no Elastic Container Registry / ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 - name: Run tests run: make test-ci diff --git a/.github/workflows/login-ecr.yml b/.github/workflows/login-ecr.yml new file mode 100644 index 0000000..a4614bd --- /dev/null +++ b/.github/workflows/login-ecr.yml @@ -0,0 +1,39 @@ +name: Reusable steps for ecr login job + +on: + workflow_call: + secrets: + AWS_PULL_ECR_ACCESS_KEY_ID: + required: true + AWS_PULL_ECR_SECRET_ACCESS_KEY: + required: true + outputs: + registry: + description: "registry from login" + value: ${{ jobs.configure_aws.outputs.registry }} + docker_username: + description: "registry from login" + value: ${{ jobs.configure_aws.outputs.docker_username }} + docker_password: + description: "registry from login" + value: ${{ jobs.configure_aws.outputs.docker_password }} + +jobs: + configure_aws: + runs-on: ubuntu-latest + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v3 + id: configure-ecr + with: + aws-access-key-id: ${{ secrets.AWS_PULL_ECR_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_PULL_ECR_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + mask-aws-account-id: "no" + - name: Login no Elastic Container Registry / ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + outputs: + registry: ${{ steps.login-ecr.outputs.registry }}/pay-docker-base-images + docker_username: ${{ steps.login-ecr.outputs.docker_username }} # More information on these outputs can be found below in the 'Docker Credentials' section + docker_password: ${{ steps.login-ecr.outputs.docker_password }} diff --git a/.github/workflows/superbowleto_build_and_push.yml b/.github/workflows/superbowleto_build_and_push.yml index 7563fd4..111bd54 100644 --- a/.github/workflows/superbowleto_build_and_push.yml +++ b/.github/workflows/superbowleto_build_and_push.yml @@ -64,6 +64,10 @@ on: required: true AWS_SECRET_ACCESS_KEY: required: true + DOCKER_IMAGES_AWS_PULL_ACCESS_KEY_ID: + required: true + DOCKER_IMAGES_AWS_PULL_SECRET_ACCESS_KEY: + required: true jobs: generate-tag: @@ -91,6 +95,22 @@ jobs: - name: checkout uses: actions/checkout@v3 + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v3 + id: configure-ecr + with: + aws-access-key-id: ${{ secrets.DOCKER_IMAGES_AWS_PULL_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.DOCKER_IMAGES_AWS_PULL_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + mask-aws-account-id: "no" + + - name: Login no Elastic Container Registry / ECR + uses: aws-actions/amazon-ecr-login@v1 + + - name: Instalar Docker Compose Standalone + run: | + docker pull 697525377503.dkr.ecr.us-east-1.amazonaws.com/pay-docker-base-images:pagarme-node8.9 + - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 with: diff --git a/Dockerfile b/Dockerfile index 1f76c0b..9ab3172 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM pagarme/docker-nodejs:8.9 +FROM 697525377503.dkr.ecr.us-east-1.amazonaws.com/pay-docker-base-images:pagarme-node8.9 COPY package.json /superbowleto/package.json COPY package-lock.json /superbowleto/package-lock.json diff --git a/Dockerfile.prod b/Dockerfile.prod index 3548cdb..de9148e 100644 --- a/Dockerfile.prod +++ b/Dockerfile.prod @@ -1,4 +1,4 @@ -FROM pagarme/docker-nodejs:8.9 +FROM 697525377503.dkr.ecr.us-east-1.amazonaws.com/pay-docker-base-images:pagarme-node8.9 # Copy package definition files COPY package.json /app/package.json @@ -11,7 +11,7 @@ RUN apk update && \ apk add python make g++ && \ npm install --production -FROM pagarme/docker-nodejs:8.9 +FROM 697525377503.dkr.ecr.us-east-1.amazonaws.com/pay-docker-base-images:pagarme-node8.9 ENV APP_NAME 'superbowleto' diff --git a/docker-compose.yml b/docker-compose.yml index 7722c2e..a4a1a29 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,21 +15,11 @@ services: retries: 5 yopa: - image: pagarme/yopa:latest - command: java -Xms64m -Xmx256m -jar uberjar.jar -c /tmp/yopa-in/config.yml -o /tmp/dev-env-aws-regions-override.xml + image: 697525377503.dkr.ecr.us-east-1.amazonaws.com/pay-docker-base-images:pagarme-yopa ports: - 47195 volumes: - ./yopa-config.yml:/tmp/yopa-in/config.yml:ro - healthcheck: - test: [ - "CMD-SHELL", - "curl -f 'http://localhost:47195?Action=GetQueueUrl&QueueName=test'", - "&&", - "curl -f 'http://localhost:47195?Action=GetQueueUrl&QueueName=boletos-to-register'", - ] - interval: 5s - retries: 5 test: build: . @@ -42,8 +32,6 @@ services: depends_on: postgres: condition: service_healthy - yopa: - condition: service_healthy superbowleto-web: condition: service_started links: