Skip to content

Commit

Permalink
added dev websockets deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
Foroxon committed Mar 31, 2024
1 parent fe2913e commit db8049c
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/deploy_websockets_dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: 🧪 Deploy Dev Websockets
on: workflow_dispatch

run-name: Deploy Dev Websockets from '${{ github.ref_name }}' branch
jobs:
deploy_microservices:
runs-on: ubuntu-latest
steps:
- name: Redeploy Dev WebSockets
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_SSH_USER }}
password: ${{ secrets.SERVER_SSH_PASSWORD }}
script: |
cd /root/ukraine_alarm_map/deploy/
git fetch --all
git checkout ${{ github.ref_name }}
git pull
bash redeploy_websocket_server_dev.sh -m ${{ secrets.MEMCACHED_HOST }} -s ${{ secrets.API_SECRET }} -i ${{ secrets.MEASUREMENT_ID }}
74 changes: 74 additions & 0 deletions deploy/redeploy_websocket_server_dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash

# Default values
MEMCACHED_HOST=""
WEBSOCKET_PORT=38447
DEBUG_LEVEL="INFO"
PING_INTERVAL=60

# Check for arguments
while [[ $# -gt 0 ]]; do
case "$1" in
-a|--tcp-port)
WEBSOCKET_PORT="$2"
shift 2
;;
-m|--memcached-host)
MEMCACHED_HOST="$2"
shift 2
;;
-s|--api-secret)
API_SECRET="$2"
shift 2
;;
-i|--measurement-id)
MEASUREMENT_ID="$2"
shift 2
;;
-d|--debug-level)
DEBUG_LEVEL="$2"
shift 2
;;
-p|--ping-interval)
PING_INTERVAL="$2"
shift 2
;;
*)
echo "Unknown argument: $1"
exit 1
;;
esac
done

echo "WEBSOCKET SERVER"

echo "MEMCACHED_HOST: $MEMCACHED_HOST"
echo "WEBSOCKET_PORT: $WEBSOCKET_PORT"
echo "DEBUG_LEVEL: $DEBUG_LEVEL"
echo "PING_INTERVAL: $PING_INTERVAL"


# Updating the Git repo
echo "Updating Git repo..."
#cd /path/to/your/git/repo
git pull

# Moving to the deployment directory
echo "Moving to deployment directory..."
cd websocket_server

# Building Docker image
echo "Building Docker image..."
docker build -t map_websocket_server_dev -f Dockerfile .

# Stopping and removing the old container (if exists)
echo "Stopping and removing old container..."
docker stop map_websocket_server_dev || true
docker rm map_websocket_server_dev || true

# Deploying the new container
echo "Deploying new container..."
docker run --name map_websocket_server_dev --restart unless-stopped -d -p "$WEBSOCKET_PORT":"$WEBSOCKET_PORT" --env WEBSOCKET_PORT="$WEBSOCKET_PORT" --env API_SECRET="$API_SECRET" --env MEASUREMENT_ID="$MEASUREMENT_ID" --env DEBUG_LEVEL="$DEBUG_LEVEL" --env PING_INTERVAL="$PING_INTERVAL" --env MEMCACHED_HOST="$MEMCACHED_HOST" map_websocket_server_dev

echo "Container deployed successfully!"

0 comments on commit db8049c

Please sign in to comment.