Skip to content

Commit

Permalink
feat: Add Docker build step
Browse files Browse the repository at this point in the history
  • Loading branch information
johnjcsmith committed Nov 30, 2024
1 parent b43a652 commit 7e9c43d
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,48 @@ jobs:
with:
path: ./load-tests/script.js

build-load-test-machine-image:
runs-on: ubuntu-latest
needs: check_changes
permissions:
id-token: write
if: ${{ needs.check_changes.outputs.load_tests == 'true' }}
#if: ${{ needs.check_changes.outputs.load_tests == 'true' && github.ref == 'refs/heads/main' }}
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: us-east-1

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build App Docker Image
env:
IMAGE_TAG: ${{ github.sha }}
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: inferable-load-test-machine
run: |
cd load-tests
VERSION=${{ github.sha }}
SHORT_VERSION=$(echo ${{ github.sha }} | cut -c 1-6)
docker buildx build \
--file Dockerfile.machine \
--push \
--cache-to mode=min,image-manifest=true,oci-mediatypes=true,type=registry,ref=$ECR_REGISTRY/$ECR_REPOSITORY:cache \
--cache-from type=registry,ref=$ECR_REGISTRY/$ECR_REPOSITORY:cache \
--build-arg="VERSION=$VERSION" \
--build-arg="SHORT_VERSION=$SHORT_VERSION" \
-t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:latest ./
build-app-image:
runs-on: ubuntu-latest
needs: check_changes
Expand Down
14 changes: 14 additions & 0 deletions load-tests/Dockerfile.machine
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:20

WORKDIR /app

COPY --link package.json ./
COPY --link package-lock.json ./

RUN npm ci

COPY machine.ts ./

RUN npm install -g tsx

CMD ["tsx", "machine.ts"]

0 comments on commit 7e9c43d

Please sign in to comment.