Skip to content

Commit 22dbee0

Browse files
committed
feat: add github action for docker image building
Signed-off-by: zongz <[email protected]>
1 parent 7c2db49 commit 22dbee0

File tree

2 files changed

+70
-1
lines changed

2 files changed

+70
-1
lines changed

.github/workflows/build.yaml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Build Docker Image
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
image_path:
7+
description: 'Full image path (e.g., docker.io/test/xxx:0.1.0)'
8+
required: true
9+
platform:
10+
description: 'Platform for the Docker image (e.g., linux/amd64, linux/arm64)'
11+
required: true
12+
build_context:
13+
description: 'Directory path for Docker build context'
14+
required: true
15+
16+
jobs:
17+
build-and-push:
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
packages: write
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v2
25+
26+
- name: Login to GitHub Container Registry
27+
uses: docker/login-action@v2
28+
with:
29+
registry: ghcr.io
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Login to docker.io
34+
uses: docker/login-action@v2
35+
with:
36+
registry: docker.io
37+
username: ${{ secrets.DOCKER_ACCOUNT }}
38+
password: ${{ secrets.DOCKER_PWD }}
39+
40+
- name: Build Docker Image
41+
run: |
42+
BUILD_CONTEXT="${{ github.event.inputs.build_context }}"
43+
ORIGINAL_IMAGE="${{ github.event.inputs.image_path }}"
44+
PLATFORM="${{ github.event.inputs.platform }}"
45+
46+
# Build the Docker image
47+
docker build --platform $PLATFORM -t $ORIGINAL_IMAGE $BUILD_CONTEXT
48+
echo "Docker image built with context $BUILD_CONTEXT and tagged as $ORIGINAL_IMAGE"
49+
50+
- name: Push Docker Image to GHCR
51+
run: |
52+
ORIGINAL_IMAGE="${{ github.event.inputs.image_path }}"
53+
IMAGE_NAME=$(basename $ORIGINAL_IMAGE)
54+
55+
# Retag for GHCR
56+
NEW_IMAGE="ghcr.io/${{ github.repository_owner }}/${IMAGE_NAME}"
57+
docker tag $ORIGINAL_IMAGE $NEW_IMAGE
58+
echo "Image retagged from $ORIGINAL_IMAGE to $NEW_IMAGE"
59+
60+
# Push to GHCR
61+
docker push $NEW_IMAGE
62+
63+
- name: Push Docker Image to DOCKER
64+
run: |
65+
ORIGINAL_IMAGE="${{ github.event.inputs.image_path }}"
66+
67+
# Push to Docker.io
68+
docker push $ORIGINAL_IMAGE
69+
echo "Docker image pushed to $ORIGINAL_IMAGE"

kcl_images/docker/kcl-builder/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ RUN ln -sf /usr/local/python3.9/bin/python3.9 /usr/bin/python3.9
2828

2929
# rust
3030
# https://www.rust-lang.org/tools/install
31-
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
31+
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain 1.83.0
3232
ENV PATH="/root/.cargo/bin:${PATH}"
3333
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
3434

0 commit comments

Comments
 (0)