Skip to content

Commit 238d7c9

Browse files
committed
ci(docker): add automated image publishing workflow and compose setup
- Add GitHub Actions workflow for automated Docker image publishing to GHCR - Configure multi-architecture builds for linux/amd64 and linux/arm64 platforms - Implement semantic versioning and branch-based image tagging strategy - Add docker-compose.yml for local development and testing - Update action.yml to reference published GHCR image instead of local Dockerfile - Enable GitHub Actions cache for faster builds and improved CI/CD performance - This enables automated image distribution and simplifies local development setup
1 parent 17ea58b commit 238d7c9

3 files changed

Lines changed: 79 additions & 1 deletion

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Publish Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
tags:
9+
- 'v*'
10+
workflow_dispatch:
11+
12+
jobs:
13+
publish:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
packages: write
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v3
25+
26+
- name: Login to GitHub Container Registry
27+
uses: docker/login-action@v3
28+
with:
29+
registry: ghcr.io
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Extract metadata
34+
id: meta
35+
uses: docker/metadata-action@v5
36+
with:
37+
images: ghcr.io/${{ github.repository }}
38+
tags: |
39+
type=ref,event=branch
40+
type=semver,pattern={{version}}
41+
type=semver,pattern={{major}}.{{minor}}
42+
type=raw,value=latest,enable={{is_default_branch}}
43+
44+
- name: Build and push
45+
uses: docker/build-push-action@v5
46+
with:
47+
context: .
48+
platforms: linux/amd64,linux/arm64
49+
push: true
50+
tags: ${{ steps.meta.outputs.tags }}
51+
labels: ${{ steps.meta.outputs.labels }}
52+
build-args: |
53+
TARGETARCH=amd64
54+
cache-from: type=gha
55+
cache-to: type=gha,mode=max

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ inputs:
1313

1414
runs:
1515
using: 'docker'
16-
image: 'Dockerfile'
16+
image: 'docker://ghcr.io/your-username/kubectl-aws-eks:latest'
1717
args:
1818
- ${{ inputs.args }}

docker-compose.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
services:
2+
aws-kubectl:
3+
build:
4+
context: .
5+
dockerfile: Dockerfile
6+
args:
7+
TARGETARCH: amd64
8+
JQ_VERSION: 1.6
9+
IAM_VERSION: 0.6.12
10+
image: aws-kubectl:latest
11+
container_name: aws-kubectl
12+
environment:
13+
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
14+
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
15+
- AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:-us-east-1}
16+
- AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN}
17+
volumes:
18+
- ~/.aws:/root/.aws:ro
19+
- ~/.kube:/root/.kube
20+
- ./:/workspace
21+
working_dir: /workspace
22+
stdin_open: true
23+
tty: true

0 commit comments

Comments
 (0)