Skip to content

Commit

Permalink
chore: adjusts docker image configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoglm committed Dec 19, 2024
1 parent 9a4b41f commit d550cf7
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 6 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/lint_tests_and_sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,31 @@ jobs:
- name: Run lint
run: npm run lint

login-erc:
uses: ./.github/workflows/login-ecr.yml@main
secrets:
AWS_PULL_ECR_ACCESS_KEY_ID: ${{ secrets.DOCKER_IMAGES_AWS_PULL_ACCESS_KEY_ID }}
AWS_PULL_ECR_SECRET_ACCESS_KEY: ${{ secrets.DOCKER_IMAGES_AWS_PULL_SECRET_ACCESS_KEY }}

test:
name: Test
runs-on: ubuntu-latest
needs: [login-erc]
steps:
- name: Checkout
uses: actions/checkout@v3

- 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: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: ${{ needs.login-erc.outputs.registry }}
username: ${{ needs.login-erc.outputs.docker_username }}
password: ${{ needs.login-erc.outputs.docker_password }}

- name: Run tests
run: make test-ci
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/login-ecr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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: small-runner-on-demand
steps:
- name: Configure AWS credentials and login
uses: pagarme/github-actions-workflows/.github/reusable-ecr-login@main
id: login-ecr
with:
AWS_PULL_ECR_ACCESS_KEY_ID: ${{ secrets.AWS_PULL_ECR_ACCESS_KEY_ID }}
AWS_PULL_ECR_SECRET_ACCESS_KEY: ${{ secrets.AWS_PULL_ECR_SECRET_ACCESS_KEY }}
outputs:
registry: ${{ steps.login-ecr.outputs.registry }}
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 }}
35 changes: 35 additions & 0 deletions .github/workflows/reusable-ecr-login.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Reusable steps for ecr login
description: this will be used to login in to docker-images ecr to download the pre-build images

inputs:
AWS_PULL_ECR_ACCESS_KEY_ID:
description: 'ECR KEY ID for pull docker-image ecr'
required: true
AWS_PULL_ECR_SECRET_ACCESS_KEY:
required: true
description: 'ECR SECRET KEY for pull docker-image ecr'
outputs:
registry:
description: "registry from login"
value: ${{ steps.login-ecr.outputs.registry }}
docker_username:
description: "username for login"
value: ${{ steps.login-ecr.outputs.docker_username_697525377503_dkr_ecr_us_east_1_amazonaws_com }}
docker_password:
description: "password for login"
value: ${{ steps.login-ecr.outputs.docker_password_697525377503_dkr_ecr_us_east_1_amazonaws_com }}

runs:
using: 'composite'
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
id: configure-ecr
with:
aws-access-key-id: ${{ inputs.AWS_PULL_ECR_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ inputs.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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM pagarme/docker-nodejs:8.9
FROM pay-docker-base-images:docker-nodejs:8.9

COPY package.json /superbowleto/package.json
COPY package-lock.json /superbowleto/package-lock.json
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM pagarme/docker-nodejs:8.9
FROM pay-docker-base-images:docker-nodejs:8.9

# Copy package definition files
COPY package.json /app/package.json
Expand All @@ -11,7 +11,7 @@ RUN apk update && \
apk add python make g++ && \
npm install --production

FROM pagarme/docker-nodejs:8.9
FROM pay-docker-base-images:docker-nodejs:8.9

ENV APP_NAME 'superbowleto'

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
retries: 5

yopa:
image: pagarme/yopa:latest
image: pay-docker-base-images:pagarme-yopa
command: java -Xms64m -Xmx256m -jar uberjar.jar -c /tmp/yopa-in/config.yml -o /tmp/dev-env-aws-regions-override.xml
ports:
- 47195
Expand Down

0 comments on commit d550cf7

Please sign in to comment.