Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

composite action to build docker images

NotificationsYou must be signed in to change notification settings

ClearTax/build-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

A GitHub composite action that builds Docker images and pushes them to Amazon ECR (Elastic Container Registry).

Description

This action streamlines the process of building Docker images and pushing them to Amazon ECR as part of your GitHub Actions workflow. It handles AWS authentication, ECR login, Docker Buildx setup, and the build/push process in a single reusable component.

Features

  • Automatic artifact download (optional)
  • AWS credentials configuration
  • Amazon ECR authentication
  • Docker Buildx setup for efficient builds
  • Docker image building with customizable parameters
  • Automatic pushing to Amazon ECR
  • Build caching for faster subsequent builds

Inputs

Required Inputs

InputDescription
aws_access_key_idAWS Access Key ID for authentication
aws_secret_access_keyAWS Secret Access Key for authentication
serviceName of the service/repository in ECR
dockerfilePath to the Dockerfile (default:Dockerfile)
versionVersion tag for the Docker image

Optional Inputs

InputDescriptionDefault
aws_regionAWS Region where ECR is locatedap-south-1
build_argsBuild arguments to pass to Docker build'' (empty)
download_artifactWhether to download artifacts before buildingtrue

Usage

jobs:build-and-push:runs-on:ubuntu-lateststeps:      -name:Checkout codeuses:actions/checkout@v3# Optional: Create and upload artifacts if needed      -name:Create artifactsrun:|          # Commands to create artifacts      -name:Upload artifactsuses:actions/upload-artifact@v3with:name:artifacts-${{github.run_id}}path:path/to/artifacts# Use the Build DockerImage action      -name:Build and Push Docker Imageuses:your-org/build-docker@v1# Replace with your actual repositorywith:aws_access_key_id:${{ secrets.AWS_ACCESS_KEY_ID }}aws_secret_access_key:${{ secrets.AWS_SECRET_ACCESS_KEY }}aws_region:ap-south-1service:my-servicedockerfile:./path/to/Dockerfileversion:${{ github.sha }}build_args:|            ARG1=value1            ARG2=value2download_artifact:true

How It Works

  1. Artifact Download (Optional): Ifdownload_artifact is set totrue, the action downloads artifacts from the current workflow run.

  2. AWS Configuration: Configures AWS credentials for authentication with ECR.

  3. ECR Login: Logs into Amazon ECR to allow pushing images.

  4. Docker Buildx Setup: Sets up Docker Buildx for efficient multi-platform builds.

  5. Build and Push: Builds the Docker image using the specified Dockerfile and pushes it to ECR with the provided tag.

Caching

This action utilizes GitHub Actions cache for Docker layers, which significantly speeds up subsequent builds by reusing previously built layers.

Notes

  • Make sure your AWS credentials have appropriate permissions to push to ECR.
  • The ECR repository must exist before using this action, or your AWS credentials must have permissions to create repositories.
  • For security, always use GitHub Secrets to store your AWS credentials.

About

composite action to build docker images

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp