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
- Start EC2 Instance: Launch an EC2 instance with specific computing resources.
- Prepare Environment: Set up
my-build-environment
for the Docker build process. - Fetch Source: Obtain the workflow source code to be used in the Docker image build.
- Check Cache: Use checksums of the
Dockerfile
,dependencies.lock
, and build version to search for existing Docker layer caches. - Build Docker Image: Execute Docker build commands, utilizing cached layers if available to speed up the process.
- Save Docker Image: After the build, save the Docker image as a tar file in the specified path.
- Output Artifact: Generate an artifact of the Docker image for deployment or further use.
相关内容
- 已提问 3 个月前
- AWS 官方已更新 1 年前
- AWS 官方已更新 2 年前