diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml new file mode 100644 index 0000000..c7b3dee --- /dev/null +++ b/.github/workflows/action.yml @@ -0,0 +1,45 @@ +name: MAXSCALE CI +on: + push: + branches: 2.2.5 + schedule: + - cron: '0 0 * * *' +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - + name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.CR_PAT }} + - name: Build and push to GHCRIO + id: docker_build + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64 + push: true + tags: | + ghcr.io/comdata/maxscale:2.2.5 + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/.project b/.project new file mode 100644 index 0000000..7793ee0 --- /dev/null +++ b/.project @@ -0,0 +1,11 @@ + + + docker-maxscale + + + + + + + + diff --git a/Dockerfile b/Dockerfile index 4be9f6c..cfbfc77 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM asosso/maxscale:2.2.5 +FROM asosso/maxscale:1.4.5 MAINTAINER toughiq@gmail.com # Setup for Galera Service (GS), not for Master-Slave environments @@ -21,6 +21,10 @@ ENV MAX_THREADS=4 \ # We copy our config creator script to the container COPY docker-entrypoint.sh / +COPY getbackendservers.sh / +COPY healthcheck.sh / +#RUN chmod +x /getbackendservers.sh /healthcheck.sh + # We expose our set Listener Ports EXPOSE $SPLITTER_PORT $ROUTER_PORT $CLI_PORT @@ -28,5 +32,8 @@ EXPOSE $SPLITTER_PORT $ROUTER_PORT $CLI_PORT # We define the config creator as entrypoint ENTRYPOINT ["/docker-entrypoint.sh"] +HEALTHCHECK --interval=5s CMD /healthcheck.sh + # We startup MaxScale as default command -CMD ["/usr/bin/maxscale","--nodaemon"] +CMD ["/usr/bin/maxscale", "--nodaemon"] +#"--log=stdout", diff --git a/README.md b/README.md index 0e0660c..3ba65c5 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,13 @@ +[![Docker Pulls](https://img.shields.io/docker/pulls/toughiq/maxscale.svg)](https://hub.docker.com/r/toughiq/maxscale/) +[![](https://images.microbadger.com/badges/image/toughiq/maxscale.svg)](https://microbadger.com/images/toughiq/maxscale "Get your own image badge on microbadger.com") + # docker-maxscale Dockerized MaxScale for Galera Cluster Backend. Can be used in combination with https://github.com/toughIQ/docker-mariadb-cluster. ## Branches & Tags There are 2 branches available, which feature __MaxScale1__ and __MaxScale2__ versions. + Since MaxScale1 is __free to use__, but MaxScale2 __needs a license from MariaDB__ in some setups, I will keep the __master__ branch with version 1.4.5 for now. This also applies to the __:latest__ tag in Docker. | Version | Branch | Docker Tag | diff --git a/docker-compose.yml b/docker-compose.yml index dd5d98b..5b87f83 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '2' services: maxscale: - image: toughiq/maxscale:2 + image: toughiq/maxscale:1 ports: - 3306:3306 - 3307:3307 diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 9fd1c41..1726330 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -2,17 +2,20 @@ set -e + # if service discovery was activated, we overwrite the BACKEND_SERVER_LIST with the # results of DNS service lookup if [ -n "$DB_SERVICE_NAME" ]; then - BACKEND_SERVER_LIST=`getent hosts tasks.$DB_SERVICE_NAME|awk '{print $1}'|tr '\n' ' '` + BACKEND_SERVER_LIST=`/getbackendservers.sh` fi +echo $BACKEND_SERVER_LIST >> /tmp/configuredbackservers # We break our IP list into array IFS=', ' read -r -a backend_servers <<< "$BACKEND_SERVER_LIST" +echo "Starting for backends: $BACKEND_SERVER_LIST" config_file="/etc/maxscale.cnf" diff --git a/getbackendservers.sh b/getbackendservers.sh new file mode 100755 index 0000000..414a75e --- /dev/null +++ b/getbackendservers.sh @@ -0,0 +1,2 @@ +#!/bin/bash +getent hosts tasks.$DB_SERVICE_NAME|awk '{print $1}'|sort|tr '\n' ' ' \ No newline at end of file diff --git a/healthcheck.sh b/healthcheck.sh new file mode 100755 index 0000000..00dd17a --- /dev/null +++ b/healthcheck.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +BACKEND_SERVER_LIST=`/getbackendservers.sh|xargs` +CONFIGURED_SERVER_LIST=`cat /tmp/configuredbackservers|xargs` + +if [[ "$BACKEND_SERVER_LIST" == "$CONFIGURED_SERVER_LIST" ]] +then + exit 0 +else + echo "$BACKEND_SERVER_LIST - $CONFIGURED_SERVER_LIST" + exit 1 +fi \ No newline at end of file