How to write and read from CodeCatalyst Workflow Action Cache?

0

I have been going through CodeCatalyst and do not see a single example, or blueprint, that demonstrates how someone would use workflow caching for Docker. An example of this directly on the docs page would be great since its quite difficult to figure out with A) poor documentation on actual usage and B) a small-ish community.

https://docs.aws.amazon.com/codecatalyst/latest/userguide/workflows-caching.html

질문됨 8달 전253회 조회
1개 답변
0

Hey!!

Maybe you will need to write your own example using the reference for workflow actions:

Based on the workflow guide shared, you can start putting together your own workflow actions. Here’s a sample that shows how to implement caching for Docker builds. Just a heads-up, this example hasn’t been tested yet, but feel free to use it as a starting point. Also, it's a good idea to kick things off with the free tier to build and test your workflows without any cost.

Name: MyDockerBuildWorkflow
SchemaVersion: 1.0
Actions:
  BuildDockerImage:
    Identifier: aws/build@v1
    Compute:
      Type: EC2
      Fleet: Linux.x86-64.Large
    Environment:
      Name: my-build-environment
    Inputs:
      Sources:
        - WorkflowSource
    Caching:
      FileCaching:
        DockerLayersCache:
          Path: /path/to/docker/cache
          RestoreKeys:
            - docker-cache-${{ checksum "Dockerfile" }}-${{ checksum "dependencies.lock" }}-${{ WorkflowSource.BUILD_VERSION }}
    Configuration:
      Container:
        Registry: DockerHub
        Image: node:18.18.2
      Steps:
        - Run: |
            docker build . \
              --cache-from /path/to/docker/cache \
              --build-arg BUILD_VERSION=${{ WorkflowSource.BUILD_VERSION }} \
              -t myimage:latest
        - Run: docker save -o /path/to/docker/cache/image.tar myimage:latest
    Outputs:
      Artifacts:
        - Name: DockerImageArtifact
          Files:
            - /path/to/docker/cache/image.tar

Details

  1. Start EC2 Instance: Launch an EC2 instance with specific computing resources.
  2. Prepare Environment: Set up my-build-environment for the Docker build process.
  3. Fetch Source: Obtain the workflow source code to be used in the Docker image build.
  4. Check Cache: Use checksums of the Dockerfile, dependencies.lock, and build version to search for existing Docker layer caches.
  5. Build Docker Image: Execute Docker build commands, utilizing cached layers if available to speed up the process.
  6. Save Docker Image: After the build, save the Docker image as a tar file in the specified path.
  7. Output Artifact: Generate an artifact of the Docker image for deployment or further use.
profile picture
전문가
답변함 8달 전

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

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

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

관련 콘텐츠