Skip to content

Commit 7d8d5d1

Browse files
Use docker/build-push-action to support multi-platform build.
1 parent 968324b commit 7d8d5d1

File tree

1 file changed

+22
-25
lines changed

1 file changed

+22
-25
lines changed

.github/workflows/dockerimage.yml

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ concurrency:
1616

1717
env:
1818
DOCKER_HUB_BASE_NAME: optuna/optuna-mcp
19-
PYTHON_VERSION: '3.12'
2019

2120
jobs:
2221

@@ -31,33 +30,31 @@ jobs:
3130

3231
- name: Set ENV
3332
run: |
34-
export TAG_NAME="py${PYTHON_VERSION}"
33+
export TAG_NAME="ci"
3534
if [ "${{ github.event_name }}" = 'release' ]; then
3635
export TAG_NAME="${{ github.event.release.tag_name }}"
3736
fi
3837
echo "HUB_TAG=${DOCKER_HUB_BASE_NAME}:${TAG_NAME}" >> $GITHUB_ENV
3938
40-
- name: Build the Docker image
41-
run: |
42-
if [ "${{ github.event_name }}" = 'release' ]; then
43-
CACHE_FROM=""
44-
else
45-
CACHE_FROM="--cache-from=${HUB_TAG}"
46-
fi
47-
docker build ${CACHE_FROM} . --build-arg PYTHON_VERSION=${PYTHON_VERSION} --file Dockerfile --tag "${HUB_TAG}"
48-
env:
49-
DOCKER_BUILDKIT: 1
50-
51-
- name: Verify the built image
52-
run: |
53-
docker run "${HUB_TAG}" optuna-mcp -h
54-
55-
- name: Login & Push to Docker Hub
39+
- name: Login to Docker Hub
5640
if: ${{ github.event_name == 'release' }}
57-
env:
58-
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
59-
run: |
60-
echo "${DOCKER_HUB_TOKEN}" | docker login -u optunabot --password-stdin
61-
docker push "${HUB_TAG}"
62-
docker tag "${HUB_TAG}" "${DOCKER_HUB_BASE_NAME}:latest"
63-
docker push "${DOCKER_HUB_BASE_NAME}:latest"
41+
uses: docker/login-action@v3
42+
with:
43+
username: optunabot
44+
password: ${{ secrets.DOCKER_HUB_TOKEN }}
45+
46+
- name: Set up QEMU
47+
uses: docker/setup-qemu-action@v3
48+
49+
- name: Set up Docker Buildx
50+
uses: docker/setup-buildx-action@v3
51+
52+
- name: Build and push
53+
uses: docker/build-push-action@v6
54+
with:
55+
context: .
56+
platforms: linux/amd64,linux/arm64
57+
push: ${{ github.event_name == 'release' }}
58+
tags: |
59+
"${HUB_TAG}"
60+
"${DOCKER_HUB_BASE_NAME}:latest"

0 commit comments

Comments
 (0)