Run integration tests with custom containers

0

As a PoC I want to build a pipeline for GitOps of policy management. When a policy is committed to a repo, I want to run an existing Docker container (available on Docker Hub) that acts as a policy engine with a REST API exposed for uploading the policies and then run queries against. What is the easiest way to accomplish this?

  1. Commit policies to Git (preferably CodeCommit)
  2. Spin up a prebuilt Docker container
  3. Run a shell script with curl commands to upload and test the validity of the policies on the Docker container
  4. Fail the pipeline if curl does not return 200.
profile pictureAWS
질문됨 9달 전272회 조회
2개 답변
0

Would something like this be the right approach to run the container inside the build?

version: 0.2

phases:
  install:
    runtime-versions:
      docker: 24

  pre_build:
    commands:
      - docker pull my-docker-image:tag
      - docker run -d --name policy-container my-docker-image:tag

  build:
    commands:
      - sh integration_tests.sh 

  post_build:
    commands:
      - docker stop policy-container
      - docker rm policy-container
profile pictureAWS
답변함 9달 전
  • The latest version is docker: 20 in a buildspec. To avoid limits you need to log in:

    version: 0.2

    env: secrets-manager: DOCKERHUB_PASS: "/dockerhub/credentials:password" DOCKERHUB_USERNAME: "/dockerhub/credentials:username" phases: install: commands: - echo pre_build step... - docker login --username $DOCKERHUB_USERNAME --password $DOCKERHUB_PASS - $(aws ecr get-login --no-include-email --region us-east-1)

    In general, your buildspec is fine.

0

You can use AWS CI/CD stack: CodeCommit, CodeBuild, CodePipeline.

https://aws.amazon.com/codecommit/

https://aws.amazon.com/codebuild/

https://aws.amazon.com/codepipeline/

In a buildspec you can define all the needed commands:

https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html

profile picture
답변함 9달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠