-
Notifications
You must be signed in to change notification settings - Fork 2
74 lines (60 loc) · 3.63 KB
/
maint.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: Create/Update Test Environment
on:
push:
branches:
- master
# paths:
# - 'backend/**'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: SSH and Deploy
uses: appleboy/ssh-action@v1.2.2
with:
host: ${{ secrets.TEST_SERVER_IP }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSHT_PRIVATE_KEY }}
script: |
cd /home/ubuntu/WSS-site/
git pull origin master
git reset --hard origin/master
# Stop and remove old test containers
docker ps -a | grep -E "backend-test|frontend-test" | awk '{print $1}' | xargs -r docker rm -f
# rm compose.yaml front-compose.yaml
# cp compose.yaml compose.yaml
# cp front-compose.yaml front-compose.yaml
# Remove old test network and volume
docker network rm app-network-test || true
# docker volume rm postgres-data-test || true
# Create a test network
docker network create app-network-test
# Create a test database volume from the production volume
#docker volume create postgres-data-test
# cp -r /var/lib/docker/volumes/wss-site_postgres-data/_data /var/lib/docker/volumes/postgres-data-test/_data
# Modify backend docker-compose.yml for test environment
sed -i 's/container_name: backend/container_name: backend-test/' compose.yaml
#sed -i 's/container_name: postgres/container_name: postgres-test/' compose.yaml
#sed -i 's/8000:8000/18000:8000/' compose.yaml
sed -i -E 's/(\s+)(app-network)(\s*:\s*$|\s*$)/\1app-network-test\3/' compose.yaml
#sed -i 's/postgres-data:/postgres-data-test:/' compose.yaml
#sed -i '/postgres-data-test:/,/driver: local/ {s/driver: local/external: true/;}' compose.yaml
sed -i '/app-network-test:/,/driver: bridge/ {s/driver: bridge/external: true/;}' compose.yaml
# Remove all payment-related sections from the backend compose file
sed -i '/payment/,+9d' compose.yaml
# Modify frontend docker-compose.yml for test environment
# sed -i 's/container_name: frontend/container_name: frontend-test/' front-compose.yaml
# sed -i 's/3000:3000/13000:3000/' front-compose.yaml
# sed -i 's/app-network/app-network-test/' front-compose.yaml
# sed -i '/app-network-test:/,/driver: bridge/ {s/driver: bridge/external: true/;}' front-compose.yaml
# Update API_ORIGIN in .env.frontend for test environment
# sed -i 's|API_ORIGIN=http://185.204.169.247:8000|API_ORIGIN=http://185.204.169.247:18000|' .env.frontend
# sed -i 's|API_ORIGIN=http://185.204.169.247:8000|API_ORIGIN=http://185.204.169.247:18000|' ./frontend/.env
#cd backend
# docker build -t wss:back .
# Build the backend and frontend images
docker build -t wss:backend backend
# docker build -t wss:frontend frontend
# cd ..
# Start the test containers
docker compose up -d