Enhance Docker workflow: add Buildx setup and update README with Docker Compose instructions
All checks were successful
Publish Container / publish (push) Successful in 3m18s
All checks were successful
Publish Container / publish (push) Successful in 3m18s
This commit is contained in:
parent
95418270f7
commit
246a189bea
3 changed files with 78 additions and 20 deletions
|
|
@ -65,6 +65,27 @@ jobs:
|
|||
echo "${HOME}/.local/bin" >> "${GITHUB_PATH}"
|
||||
"${HOME}/.local/bin/docker" --version
|
||||
|
||||
- name: Ensure Docker Buildx exists
|
||||
run: |
|
||||
set -eu
|
||||
if docker buildx version >/dev/null 2>&1; then
|
||||
docker buildx version
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ARCH="$(uname -m)"
|
||||
case "${ARCH}" in
|
||||
x86_64) BUILDX_ARCH="amd64" ;;
|
||||
aarch64|arm64) BUILDX_ARCH="arm64" ;;
|
||||
*) echo "Unsupported architecture for Docker Buildx bootstrap: ${ARCH}"; exit 1 ;;
|
||||
esac
|
||||
|
||||
BUILDX_VERSION="v0.21.1"
|
||||
mkdir -p "${HOME}/.docker/cli-plugins"
|
||||
curl -fsSL "https://github.com/docker/buildx/releases/download/${BUILDX_VERSION}/buildx-${BUILDX_VERSION}.linux-${BUILDX_ARCH}" -o "${HOME}/.docker/cli-plugins/docker-buildx"
|
||||
chmod +x "${HOME}/.docker/cli-plugins/docker-buildx"
|
||||
docker buildx version
|
||||
|
||||
# Simplified: we trust DOCKER_HOST (default to tcp://172.17.0.1:2375). If you
|
||||
# need a different endpoint, set the Forgejo variable `DOCKER_HOST`.
|
||||
|
||||
|
|
@ -75,6 +96,13 @@ jobs:
|
|||
docker version
|
||||
docker info >/dev/null
|
||||
|
||||
- name: Create Buildx builder
|
||||
run: |
|
||||
set -eu
|
||||
docker buildx rm forgejo-builder >/dev/null 2>&1 || true
|
||||
docker buildx create --name forgejo-builder --driver docker-container --use
|
||||
docker buildx inspect --bootstrap
|
||||
|
||||
- name: Restore and publish app
|
||||
run: dotnet publish src/MaddoScientisto.Web/MaddoScientisto.Web.csproj -c Release -o ./artifacts/publish
|
||||
|
||||
|
|
@ -82,17 +110,14 @@ jobs:
|
|||
run: |
|
||||
echo "${{ secrets.FORGEJO_REGISTRY_TOKEN }}" | docker login "${REGISTRY}" -u "${{ secrets.FORGEJO_REGISTRY_USERNAME }}" --password-stdin
|
||||
|
||||
- name: Build image
|
||||
- name: Build and push image
|
||||
run: |
|
||||
set -eu
|
||||
IMAGE_REF="${REGISTRY}/${IMAGE_NAMESPACE}/${IMAGE_NAME}"
|
||||
SHORT_SHA="$(echo "${GITHUB_SHA}" | cut -c1-12)"
|
||||
docker build -t "${IMAGE_REF}:sha-${SHORT_SHA}" -t "${IMAGE_REF}:latest" .
|
||||
|
||||
- name: Push image tags
|
||||
run: |
|
||||
set -eu
|
||||
IMAGE_REF="${REGISTRY}/${IMAGE_NAMESPACE}/${IMAGE_NAME}"
|
||||
SHORT_SHA="$(echo "${GITHUB_SHA}" | cut -c1-12)"
|
||||
docker push "${IMAGE_REF}:sha-${SHORT_SHA}"
|
||||
docker push "${IMAGE_REF}:latest"
|
||||
docker buildx build \
|
||||
--builder forgejo-builder \
|
||||
--tag "${IMAGE_REF}:sha-${SHORT_SHA}" \
|
||||
--tag "${IMAGE_REF}:latest" \
|
||||
--push \
|
||||
.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue