Skip to content

Commit

Permalink
Update: 迁移使用 redis 新容器
Browse files Browse the repository at this point in the history
  • Loading branch information
NHZEX committed Apr 6, 2024
1 parent 20b6e6f commit 617a4b4
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/actions/ci-prepare/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
47 changes: 27 additions & 20 deletions .github/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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_PASSWORD: ${REDIS_SERVER_PASSWORD:-l83aa26}
PGSQL_SERVER_HOST: postgres
MYSQL_SERVER_PASSWORD: ""
AMQP_SERVER_HOST: "rabbitmq"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions .github/service/redis-tls/redis-overrides.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
unixsocket /run/shared/redis.sock
unixsocketperm 777
29 changes: 21 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,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
Expand Down Expand Up @@ -152,7 +152,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 }}
Expand Down Expand Up @@ -199,10 +199,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"
Expand All @@ -212,6 +209,7 @@ jobs:
- name: Test
if: ${{ env.test_prepared && always() }}
env:
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"
run: composer test
Expand All @@ -224,6 +222,7 @@ jobs:
- name: Test redis
if: ${{ env.test_prepared && always() }}
env:
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"
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"
Expand All @@ -237,6 +236,8 @@ jobs:
run: composer test-redis
- name: Test swoole
if: ${{ env.test_prepared && always() }}
env:
REDIS_SERVER_PASSWORD: "l83aa26"
run: composer test-swoole
- name: Test workerman
if: ${{ env.test_prepared && always() }}
Expand All @@ -249,21 +250,33 @@ jobs:
run: composer test-jwt
- name: Test queue
if: ${{ env.test_prepared && always() }}
env:
REDIS_SERVER_PASSWORD: "l83aa26"
run: composer test-queue
- name: Test amqp
if: ${{ env.test_prepared && always() }}
env:
REDIS_SERVER_PASSWORD: "l83aa26"
run: composer test-amqp
- name: Test kafka
if: ${{ env.test_prepared && always() }}
env:
REDIS_SERVER_PASSWORD: "l83aa26"
run: composer test-kafka
- name: Test grpc
if: ${{ env.test_prepared && always() }}
env:
REDIS_SERVER_PASSWORD: "l83aa26"
run: composer test-grpc
- name: Test snowflake
if: ${{ env.test_prepared && always() }}
env:
REDIS_SERVER_PASSWORD: "l83aa26"
run: composer test-snowflake
- name: Test mqtt
if: ${{ env.test_prepared && always() }}
env:
REDIS_SERVER_PASSWORD: "l83aa26"
run: composer test-mqtt
- name: Test smarty
if: ${{ env.test_prepared && always() }}
Expand Down

0 comments on commit 617a4b4

Please sign in to comment.