@@ -71,13 +71,10 @@ jobs:
7171
7272 # Function to check if Redis is ready
7373 check_redis() {
74- redis-cli ping || return 1
74+ redis-cli -h 127.0.0.1 ping || return 1
7575 return 0
7676 }
7777
78- # Get host IP address
79- HOST_IP=\$(ip route get 1 | awk '{print \$7;exit}')
80-
8178 # Create deployment directory
8279 sudo mkdir -p /yash-code/Trades
8380
9592 sudo sed -i 's/# maxmemory-policy noeviction/maxmemory-policy allkeys-lru/' /etc/redis/redis.conf
9693 sudo sed -i 's/protected-mode yes/protected-mode no/' /etc/redis/redis.conf
9794 sudo sed -i 's/bind 127.0.0.1/bind 0.0.0.0/' /etc/redis/redis.conf
95+ sudo sed -i 's/# requirepass foobared/requirepass tradingapp/' /etc/redis/redis.conf
96+
97+ # Configure firewall
98+ echo "Configuring firewall..."
99+ sudo ufw allow 6379/tcp
98100
99101 # Start Redis service
100102 echo "Starting Redis service..."
@@ -172,9 +174,9 @@ jobs:
172174 JWT_SECRET=${JWT_SECRET}
173175 NODE_ENV=production
174176 PORT=3001
175- REDIS_HOST=\${HOST_IP}
177+ REDIS_HOST=127.0.0.1
176178 REDIS_PORT=6379
177- REDIS_PASSWORD=
179+ REDIS_PASSWORD=tradingapp
178180 REDIS_DB=0
179181 EOF"
180182
@@ -188,13 +190,14 @@ jobs:
188190 --network trading-network \\
189191 -p 3001:3001 \\
190192 --restart unless-stopped \\
193+ --add-host=host.docker.internal:host-gateway \\
191194 -e DATABASE_URL="postgresql://postgres:postgres@timescaledb:5432/trading_app?schema=public" \\
192195 -e JWT_SECRET="${JWT_SECRET}" \\
193196 -e NODE_ENV="production" \\
194197 -e PORT="3001" \\
195- -e REDIS_HOST="\${HOST_IP} " \\
198+ -e REDIS_HOST="host.docker.internal " \\
196199 -e REDIS_PORT="6379" \\
197- -e REDIS_PASSWORD="" \\
200+ -e REDIS_PASSWORD="tradingapp " \\
198201 -e REDIS_DB="0" \\
199202 ${DOCKER_USERNAME}/trading-app-backend:latest
200203
0 commit comments