Skip to content

self-hosted multiarch-build #5

self-hosted multiarch-build

self-hosted multiarch-build #5

name: self-hosted multiarch-build
on:
workflow_dispatch:
env:
DOCKER_PATH: "/install/docker"
REPO: "lemmav"
DOCKER_IMAGE_PREFIX: "4testing-docspace"
DOCKERFILE: "Dockerfile.app"
FILE: "build.yml"
PRODUCT_NAME: "4testing-docspace-socket"
REGISTRY_URL: "https://hub.docker.com/v2/repositories"
jobs:
build:
runs-on: self-hosted
strategy:
matrix:
platform: [linux/amd64]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Free Disk Space
run: |
sudo rm -rf /usr/local/lib/android /opt/ghc
sudo docker image prune --all --force
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Test Container
run: |
echo "test ${{github.head_ref}}"
cd .${DOCKER_PATH}
DOCKER_TAG=$(curl -s -H -X ${REGISTRY_URL}/${REPO}/${PRODUCT_NAME}/tags/?page_size=100 | jq -r '.results|.[]|.name' | grep -E '^[0-9]+(\.[0-9]+){3}$' | head -n1)
DOCKER_IMAGES=$(grep -oP '(?<=image: ")[^"]+' $FILE | sed -e "s/\${REPO}/$REPO/g ; s/\${DOCKER_IMAGE_PREFIX}/$DOCKER_IMAGE_PREFIX/g ; s/\${DOCKER_TAG}/$DOCKER_TAG/g" | tr '\n' ' ' )
IFS=" " read -a IMAGES <<< "$DOCKER_IMAGES"
docker network create -d bridge onlyoffice
for IMAGE in ${IMAGES[@]}; do
NEW_IMAGE=$(echo $IMAGE | sed -Ee "s/4testing-//; s/\.[0-9]+$//")
NEW_IMAGE_LATEST=$(echo $IMAGE | sed -Ee "s/4testing-//; s/$DOCKER_TAG/latest/")
sleep 30
docker-compose -f db.yml up -d
sleep 30
docker-compose -f elasticsearch.yml up -d
sleep 30
docker-compose -f redis.yml up -d
sleep 30
docker-compose -f rabbitmq.yml up -d
sleep 30
docker-compose -f healthchecks.yml up -d
sleep 30
docker-compose -f migration-runner.yml up -d
sleep 30
docker-compose -f docspace.yml up -d
sleep 30
docker-compose -f notify.yml up -d
for CONTAINER_NAME in db elasticsearch redis rabbitmq healthchecks migration-runner docspace notify; do
CONTAINER_IDS=$(docker-compose -f ${CONTAINER_NAME}.yml ps -q --all)
for CONTAINER_ID in $CONTAINER_IDS; do
CONTAINER_STATUS=$(docker inspect -f '{{.State.Status}}' $CONTAINER_ID)
if [ "$CONTAINER_STATUS" == "restarting" ] || [ "$CONTAINER_STATUS" == "exited" ]; then
echo "Error: $CONTAINER_NAME container is $CONTAINER_STATUS."
exit 1
else
echo "$CONTAINER_NAME container is running."
fi
done
done
done
shell: bash