diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9cdfc21f..f0b6d5c6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/load-tests/Dockerfile.machine b/load-tests/Dockerfile.machine new file mode 100644 index 00000000..143a57bd --- /dev/null +++ b/load-tests/Dockerfile.machine @@ -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"]