Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Docker Container With Local Deb To Reduce Docker Container Bui… #582

Merged
merged 1 commit into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 35 additions & 53 deletions .github/workflows/integrationTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,58 +27,6 @@ concurrency:
cancel-in-progress: true

jobs:
MakeDockerImage:
name: 'MakeDockerImage'
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v3

- name: Cache if success
id: build-docker-image
uses: actions/cache@v2
with:
path: |
RELEASE_NOTES
key: build-docker-image-${{ github.run_id }}

- name: Configure AWS Credentials
if: steps.build-docker-image.outputs.cache-hit != 'true'
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ env.TERRAFORM_AWS_ASSUME_ROLE }}
aws-region: us-west-2

- name: Login ECR
if: steps.build-docker-image.outputs.cache-hit != 'true'
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Set up Docker Buildx
if: steps.build-docker-image.outputs.cache-hit != 'true'
uses: docker/setup-buildx-action@v1

- name: Set up QEMU
if: steps.build-docker-image.outputs.cache-hit != 'true'
uses: docker/setup-qemu-action@v1

#Build the cloudwatch agent image for two primary reasons:
#-Using the cloudwatch agent image to do the integration test (can be used for internal)
#-Export it for the future use in CD release pipeline
#Documentation: https://github.com/docker/build-push-action
- name: Build Cloudwatch Agent Image
uses: docker/build-push-action@v2
if: steps.build-docker-image.outputs.cache-hit != 'true'
with:
file: amazon-cloudwatch-container-insights/cloudwatch-agent-dockerfile/source/Dockerfile
context: .
push: true
tags: |
${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_INTEGRATION_TEST_REPO }}:${{ github.sha }}
platforms: linux/amd64, linux/arm64

MakeBinary:
name: 'MakeBinary'
runs-on: ubuntu-latest
Expand Down Expand Up @@ -138,6 +86,40 @@ jobs:
- name: Upload to s3
if: steps.cached_binaries.outputs.cache-hit != 'true'
run: aws s3 cp build/bin s3://${S3_INTEGRATION_BUCKET}/integration-test/binary/${{ github.sha }} --recursive

- name: Login ECR
if: steps.cached_binaries.outputs.cache-hit != 'true'
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Set up Docker Buildx
if: steps.cached_binaries.outputs.cache-hit != 'true'
uses: docker/setup-buildx-action@v1

- name: Set up QEMU
if: steps.cached_binaries.outputs.cache-hit != 'true'
uses: docker/setup-qemu-action@v1

# build dir is ignored in our .dockerignore thus need to copy to another dir
- name: Copy Binary For Agent Image Build
if: steps.cached_binaries.outputs.cache-hit != 'true'
run: cp -r build/bin/linux/* .

#Build the cloudwatch agent image for two primary reasons:
#-Using the cloudwatch agent image to do the integration test (can be used for internal)
#-Export it for the future use in CD release pipeline
#Documentation: https://github.com/docker/build-push-action
- name: Build Cloudwatch Agent Image
uses: docker/build-push-action@v2
if: steps.cached_binaries.outputs.cache-hit != 'true'
with:
file: amazon-cloudwatch-container-insights/cloudwatch-agent-dockerfile/localdeb/Dockerfile
context: .
push: true
tags: |
${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_INTEGRATION_TEST_REPO }}:${{ github.sha }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is ECR_INTEGRATION_TEST_REPO already documented in our integ test setup README?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@khanhntd please comment as you wrote this. I just changed where this happens in build so I can copy the deb.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not documented ECR_INTEGRATION_TEST_REPO in the README. Will take an action on this.

platforms: linux/amd64, linux/arm64

GenerateTestMatrix:
name: 'GenerateTestMatrix'
runs-on: ubuntu-latest
Expand Down Expand Up @@ -576,7 +558,7 @@ jobs:
ECSFargateIntegrationTest:
name: 'ECSFargateIntegrationTest'
runs-on: ubuntu-latest
needs: [MakeDockerImage, GenerateTestMatrix]
needs: [MakeBinary, GenerateTestMatrix]
strategy:
fail-fast: false
matrix:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
ARG BUILD_IMAGE=ubuntu:latest
FROM $BUILD_IMAGE as build

ARG TARGETARCH

RUN apt-get update && \
apt-get install -y ca-certificates && \
rm -rf /var/lib/apt/lists/*

COPY amazon-cloudwatch-agent.deb /tmp/amazon-cloudwatch-agent.deb
COPY ${TARGETARCH}/amazon-cloudwatch-agent.deb /tmp/amazon-cloudwatch-agent.deb

RUN dpkg -i -E /tmp/amazon-cloudwatch-agent.deb && \
rm -rf /tmp/* && \
Expand Down