-
Notifications
You must be signed in to change notification settings - Fork 1
/
batch.ps1
111 lines (106 loc) · 2.65 KB
/
batch.ps1
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# PRODUCTION
## Stop all containers
function Stop {
docker container stop $(docker ps -aq)
}
## Remove all containers
function Delete {
docker container rm $(docker ps -aq)
}
# DEVELOPMENT
## Temporarily shut down containers
function Remove {
docker-compose down --remove-orphans
}
## Build containers from scratch
function Build {
docker-compose -f docker-compose.dev.yml up --build
}
## Start temporarily stopped containers again
function Up {
docker-compose -f docker-compose.dev.yml up
}
## List all containers currently present
function PS {
docker-compose ps -a
}
# CONTAINERS
## Client container
function Client-Container {
docker exec -it client bash
}
## Backend container
function Backend-Container {
docker exec -it backend bash
}
## Web Server Container
function Web-Server-Container {
docker exec -it web-server bash
}
## PostGre Container
function Primary-Container {
docker exec -it primary bash
}
## MongoDB Container
function Secondary-Container {
docker exec -it secondary bash
}
## Cache container
function Cache-Container {
docker exec -it cache bash
}
## SSH to containers
function SSH {
ssh `grep 'deploy_user=' ./ansible/hosts | tail -n1 | awk -F'=' '{ print $2}'`@`awk 'f{print;f=0} /[production]/{f=1}' ./ansible/hosts | head -n 1
}
# TESTING
## Testing Server And Client
function Test {
Write-Host "------------------"
Write-Host "Testing For Server"
Write-Host "------------------"
cd ./Tests/server/
dotnet test
Write-Host "------------------"
Write-Host "Testing For Client"
Write-Host "------------------"
cd ../../
./client/node_modules/jest/node_modules/.bin/jest ./client/src/tests/App.test.tsx
}
function Lint {
Write-Host "Linting client ... "
./node_modules/.bin/eslint ./client/
}
function Lint-Fix {
Write-Host "Running prettier and eslint on client for possible fix ... "
./node_modules/.bin/prettier --write ./client/src/**/*.{"ts","tsx"}
./node_modules/.bin/eslint ./client/ --fix
}
# DOTNET
## Make pre release for the project
function Prerelease {
npm run --prefix client webpack:build
./node_modules/.bin/cross-env ASPNETCORE_ENVIRONMENT=Production
cd ./server/ && dotnet publish -c Release
}
## After making a pre release
function Postinstall {
dotnet restore ./server/
}
## Create migration
function Migrate {
# TODO: Create script to migrate database for serve {
cd ./server/
# node ./Scripts/create-migration.js
dotnet ef database update
}
# ANSIBLE
## Provision Containers
function Provision {
ansible-playbook -l production -i ./ansible/config.yml ./ansible/provision.yml
}
## Deploy to containers
function Deploy {
npm run prerelease
ansible-playbook -l production -i ./ansible/config.yml ./ansible/deploy.yml
}