From d3eaf699c8e8a0479d2fc003fc2fad778ba401ab Mon Sep 17 00:00:00 2001 From: auooru Date: Sat, 6 Apr 2024 22:49:22 +0800 Subject: [PATCH] =?UTF-8?q?Update:=20=E8=BF=81=E7=A7=BB=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=20redis=20=E6=96=B0=E5=AE=B9=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/actions/ci-prepare/action.yml | 2 +- .github/docker-compose.yml | 49 +++++++++++-------- .../service/redis-tls/redis-overrides.conf | 2 + .github/workflows/ci.yml | 25 ++++------ 4 files changed, 41 insertions(+), 37 deletions(-) create mode 100644 .github/service/redis-tls/redis-overrides.conf diff --git a/.github/actions/ci-prepare/action.yml b/.github/actions/ci-prepare/action.yml index 3978c1cad..b92618117 100644 --- a/.github/actions/ci-prepare/action.yml +++ b/.github/actions/ci-prepare/action.yml @@ -14,7 +14,7 @@ runs: run: | docker network create imi-ci-service-network --subnet 172.10.12.0/24 docker compose -f ./.github/service/redis-cluster/docker-compose.yml up -d - docker compose -f ./.github/docker-compose.yml up -d ${{ inputs.env }} redis-new + docker compose -f ./.github/docker-compose.yml up -d ${{ inputs.env }} docker exec ${{ inputs.env }} php -v docker exec ${{ inputs.env }} php -m docker exec ${{ inputs.env }} php --ri redis diff --git a/.github/docker-compose.yml b/.github/docker-compose.yml index ee1a0d77e..544e0531e 100644 --- a/.github/docker-compose.yml +++ b/.github/docker-compose.yml @@ -40,28 +40,30 @@ services: volumes: - "${GITHUB_WORKSPACE}:/imi:rw" - redis: - image: redis:6-alpine - container_name: redis - depends_on: - - shared-tmp - command: redis-server /etc/redis.conf - volumes: - - ./redis.conf:/etc/redis.conf - - /run/shared:/run/shared - ports: - - 6379:6379 +# redis: +# image: redis:6-alpine +# container_name: redis +# depends_on: +# - shared-tmp +# command: redis-server /etc/redis.conf +# volumes: +# - ./redis.conf:/etc/redis.conf +# - /run/shared:/run/shared +# ports: +# - 6379:6379 - redis-new: + redis: image: bitnami/redis:7.2 - container_name: redis-new + container_name: redis depends_on: - shared-tmp volumes: - "${GITHUB_WORKSPACE}/.github/service/redis-tls/certs:/opt/bitnami/redis/certs" + - "${GITHUB_WORKSPACE}/.github/service/redis-tls/redis-overrides.conf:/opt/bitnami/redis/redis-overrides.conf" - /run/shared:/run/shared environment: - REDIS_PORT_NUMBER: 6377 + REDIS_OVERRIDES_FILE: "/opt/bitnami/redis/redis-overrides.conf" + REDIS_PORT_NUMBER: 6379 REDIS_PASSWORD: "l83aa26" REDIS_TLS_ENABLED: "true" REDIS_TLS_PORT_NUMBER: 6443 @@ -71,13 +73,18 @@ services: REDIS_TLS_CA_FILE: "/opt/bitnami/redis/certs/ca.crt" REDIS_TLS_AUTH_CLIENTS: "yes" healthcheck: - test: ["CMD-SHELL", "redis-cli -h 127.0.0.1 -p 6377 -a l83aa26 INFO | grep 'redis_version'"] + test: ["CMD-SHELL", "redis-cli -h 127.0.0.1 -p $${REDIS_PORT_NUMBER:-6379} -a $${REDIS_PASSWORD} INFO | grep 'redis_version'"] interval: 3s timeout: 60s retries: 30 ports: - - "6377:6377" + - "6379:6379" - "6443:6443" + networks: + proxies: + aliases: + - redis + ipv4_address: 172.10.12.111 rabbitmq: container_name: rabbitmq @@ -124,13 +131,13 @@ services: - shared-tmp - mysql - redis - - redis-new - rabbitmq - kafka1 - postgres environment: MYSQL_SERVER_HOST: mysql - REDIS_SERVER_HOST: ${REDIS_SERVER_HOST} + REDIS_SERVER_HOST: ${REDIS_SERVER_HOST:-redis} + REDIS_SERVER_PASSWORD: ${REDIS_SERVER_PASSWORD:-l83aa26} PGSQL_SERVER_HOST: postgres MYSQL_SERVER_PASSWORD: "" AMQP_SERVER_HOST: "rabbitmq" @@ -140,7 +147,7 @@ services: REDIS_SERVER_CLUSTER_SEEDS: "172.10.12.2:6379,172.10.12.3:6379,172.10.12.4:6379,172.10.12.5:6379,172.10.12.6:6379,172.10.12.7:6379" REDIS_SERVER_TLS_CLUSTER_SEEDS: "172.10.12.2:6443,172.10.12.3:6443,172.10.12.4:6443,172.10.12.5:6443,172.10.12.6:6443,172.10.12.7:6443" REDIS_SERVER_UNIX_SOCK: "/run/shared/redis.sock" - REDIS_SERVER_TLS_HOST: "redis-new" + REDIS_SERVER_TLS_HOST: "redis" REDIS_SERVER_TLS_PORT: "6443" REDIS_SERVER_TLS_PASSWORD: "l83aa26" REDIS_SERVER_TLS_CA_FILE: "/imi/.github/service/redis-tls/certs/ca.crt" @@ -162,13 +169,13 @@ services: - shared-tmp - mysql - redis - - redis-new - rabbitmq - kafka1 - postgres environment: MYSQL_SERVER_HOST: mysql REDIS_SERVER_HOST: ${REDIS_SERVER_HOST} + REDIS_SERVER_PASSWORD: ${REDIS_SERVER_PASSWORD:-l83aa26} PGSQL_SERVER_HOST: postgres MYSQL_SERVER_PASSWORD: "" AMQP_SERVER_HOST: "rabbitmq" @@ -178,7 +185,7 @@ services: REDIS_SERVER_CLUSTER_SEEDS: "172.10.12.2:6379,172.10.12.3:6379,172.10.12.4:6379,172.10.12.5:6379,172.10.12.6:6379,172.10.12.7:6379" REDIS_SERVER_TLS_CLUSTER_SEEDS: "172.10.12.2:6443,172.10.12.3:6443,172.10.12.4:6443,172.10.12.5:6443,172.10.12.6:6443,172.10.12.7:6443" REDIS_SERVER_UNIX_SOCK: "/run/shared/redis.sock" - REDIS_SERVER_TLS_HOST: "redis-new" + REDIS_SERVER_TLS_HOST: "redis" REDIS_SERVER_TLS_PORT: "6443" REDIS_SERVER_TLS_PASSWORD: "l83aa26" REDIS_SERVER_TLS_CA_FILE: "/imi/.github/service/redis-tls/certs/ca.crt" diff --git a/.github/service/redis-tls/redis-overrides.conf b/.github/service/redis-tls/redis-overrides.conf new file mode 100644 index 000000000..d3f0f7abe --- /dev/null +++ b/.github/service/redis-tls/redis-overrides.conf @@ -0,0 +1,2 @@ +unixsocket /run/shared/redis.sock +unixsocketperm 777 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7d584a87c..6d97ea9e8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,6 @@ jobs: REPOSITORY_OWNER: ${{ github.repository_owner }} IMAGE_VERSION: ${{ matrix.swoole.version }} MYSQL_DOCKER_VERSION: "8.0" - REDIS_SERVER_HOST: redis ROADRUNNER_DOCKER_VERSION: ${{ matrix.roadrunner }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: @@ -61,13 +60,13 @@ jobs: run: | docker ps docker logs shared-tmp || true - docker logs redis-new || true + docker logs redis || true docker exec ${ENV_SERVICE} bash -c "ls -lha /run/shared" echo ">>> redis-cluster-node-0" docker exec ${ENV_SERVICE} bash -c "echo -e 'auth l83aa26\r\ninfo server' | nc redis-cluster-node-0-1 6379 -w 1" docker exec ${ENV_SERVICE} bash -c "echo -e 'auth l83aa26\r\ncluster info\r\ncluster nodes' | nc redis-cluster-node-0-1 6379 -w 1" - echo ">>> redis-new" - docker exec ${ENV_SERVICE} bash -c "echo -e 'auth l83aa26\r\ninfo server' | nc redis-new 6377 -w 1" + echo ">>> redis" + docker exec ${ENV_SERVICE} bash -c "echo -e 'auth l83aa26\r\ninfo server' | nc redis 6379 -w 1" - name: Test if: ${{ env.test_prepared && always() }} run: docker exec ${ENV_SERVICE} composer test @@ -143,6 +142,10 @@ jobs: env: MYSQL_DOCKER_VERSION: "8.0" GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REDIS_SERVER_HOST: "127.0.0.1" + REDIS_SERVER_PASSWORD: "l83aa26" + REDIS_SERVER_CLUSTER_PASSWORD: "l83aa26" + REDIS_SERVER_CLUSTER_SEEDS: "172.10.12.2:6379,172.10.12.3:6379,172.10.12.4:6379,172.10.12.5:6379,172.10.12.6:6379,172.10.12.7:6379" steps: - name: Checkout uses: actions/checkout@v4 @@ -152,7 +155,7 @@ jobs: sudo apt update && sudo apt install -y rsync netcat-openbsd tree docker network create imi-ci-service-network --subnet 172.10.12.0/24 docker compose -f ./.github/service/redis-cluster/docker-compose.yml up -d - docker compose -f ./.github/docker-compose.yml up -d mysql postgres redis redis-new rabbitmq kafka1 + docker compose -f ./.github/docker-compose.yml up -d mysql postgres redis rabbitmq kafka1 echo "127.0.0.1 kafka1" | sudo tee -a /etc/hosts - name: Setup swoole-cli run: .github/script/install-swoole-cli.sh ${{ matrix.swoole-cli }} @@ -199,10 +202,7 @@ jobs: find /run/shared -name *.sock tree -alfugh /run/shared echo ">>> redis" - echo -e 'info server' | nc 127.0.0.1 6379 -w 1 - echo ">>> =====" - echo ">>> redis-new" - echo -e 'auth l83aa26\r\ninfo server' | nc 127.0.0.1 6377 -w 1 + echo -e 'auth l83aa26\r\ninfo server' | nc 127.0.0.1 6379 -w 1 echo ">>> =====" docker compose -f ./.github/service/redis-cluster/docker-compose.yml logs echo ">>> redis-cluster" @@ -211,9 +211,6 @@ jobs: docker compose -f ./.github/service/redis-cluster/docker-compose.yml exec node-0 cat /bitnami/redis/data/nodes.conf - name: Test if: ${{ env.test_prepared && always() }} - env: - REDIS_SERVER_CLUSTER_PASSWORD: "l83aa26" - REDIS_SERVER_CLUSTER_SEEDS: "172.10.12.2:6379,172.10.12.3:6379,172.10.12.4:6379,172.10.12.5:6379,172.10.12.6:6379,172.10.12.7:6379" run: composer test - name: Test connection-center if: ${{ env.test_prepared && always() }} @@ -224,10 +221,8 @@ jobs: - name: Test redis if: ${{ env.test_prepared && always() }} env: - REDIS_SERVER_CLUSTER_PASSWORD: "l83aa26" - REDIS_SERVER_CLUSTER_SEEDS: "172.10.12.2:6379,172.10.12.3:6379,172.10.12.4:6379,172.10.12.5:6379,172.10.12.6:6379,172.10.12.7:6379" - REDIS_SERVER_TLS_CLUSTER_SEEDS: "172.10.12.2:6443,172.10.12.3:6443,172.10.12.4:6443,172.10.12.5:6443,172.10.12.6:6443,172.10.12.7:6443" REDIS_SERVER_UNIX_SOCK: "/run/shared/redis.sock" + REDIS_SERVER_TLS_CLUSTER_SEEDS: "172.10.12.2:6443,172.10.12.3:6443,172.10.12.4:6443,172.10.12.5:6443,172.10.12.6:6443,172.10.12.7:6443" REDIS_SERVER_TLS_HOST: "127.0.0.1" REDIS_SERVER_TLS_PORT: "6443" REDIS_SERVER_TLS_PASSWORD: "l83aa26"