-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.gitlab-ci.yml
191 lines (174 loc) · 7.33 KB
/
.gitlab-ci.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
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
stages:
- test
- build
- deploy
image:
ubuntu:jammy
test:
image: node:16
stage: test
script:
- yarn install --ignore-platform
- CI=true yarn test --all --colors
build:dev:
image: node:16
stage: build
script:
- yarn install --ignore-platform
- REACT_APP_VERSION=$(git describe --tags --always --dirty=+) REACT_APP_API_URL=https://api.dev.inowas.com REACT_APP_SENSORS_URL=https://api.dev.morpheus.inowas.com/sensors NODE_OPTIONS=--max_old_space_size=4096 yarn build
- VERSION=$(git describe --tags --always --dirty=+) && DATE=$(date +%Y-%m-%dT%H:%M:%S) && sed -i "s/@@__VERSION__@@/${VERSION}/g;s/@@__BUILT__@@/${DATE}/g" ./build/index.html
artifacts:
paths:
- build/
only:
- dev
- tags
deploy:dev:
image: ubuntu:latest
stage: deploy
dependencies:
- build:dev
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- mkdir -p ~/.ssh
- eval $(ssh-agent -s)
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- apt-get install rsync -y
script:
- ssh -p22 $SSH_CREDENTIALS_DEVELOPMENT_SERVER "cd $DEVELOPMENT_PATH && docker compose down"
- ssh -p22 $SSH_CREDENTIALS_DEVELOPMENT_SERVER "cd $DEVELOPMENT_PATH && rm -rf public && mkdir -p public"
- scp -P22 ./infrastructure/docker-compose.yml $SSH_CREDENTIALS_DEVELOPMENT_SERVER:/$DEVELOPMENT_PATH/docker-compose.yml
- rsync -rav -e ssh ./build/ $SSH_CREDENTIALS_DEVELOPMENT_SERVER:/$DEVELOPMENT_PATH/public/
- ssh -p22 $SSH_CREDENTIALS_DEVELOPMENT_SERVER "cd $DEVELOPMENT_PATH && docker compose up -d --force-recreate"
environment:
name: development
url: https://dev.inowas.com
only:
- dev
- tags
build:smart-control:
image: node:16
stage: build
script:
- yarn install --ignore-platform
- REACT_APP_VERSION=$(git describe --tags --always --dirty=+) REACT_APP_API_URL=https://api.dss.smart-control.inowas.com REACT_APP_USERS_CAN_REGISTER=false REACT_APP_PUBLIC_PROJECTS_ACCESS=false NODE_OPTIONS=--max_old_space_size=4096 yarn build
- VERSION=$(git describe --tags --always --dirty=+) && DATE=$(date +%Y-%m-%dT%H:%M:%S) && sed -i "s/@@__VERSION__@@/${VERSION}/g;s/@@__BUILT__@@/${DATE}/g" ./build/index.html
artifacts:
paths:
- build/
only:
- tags
deploy:smart-control:
stage: deploy
dependencies:
- build:smart-control
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- mkdir -p ~/.ssh
- eval $(ssh-agent -s)
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- apt-get install rsync -y
script:
- ssh -p22 $SSH_CREDENTIALS_SMART_CONTROL_SERVER "cd $SMART_CONTROL_PATH && docker compose down"
- ssh -p22 $SSH_CREDENTIALS_SMART_CONTROL_SERVER "cd $SMART_CONTROL_PATH && rm -rf public && mkdir -p public"
- scp -P22 ./infrastructure/docker-compose.yml $SSH_CREDENTIALS_SMART_CONTROL_SERVER:/$SMART_CONTROL_PATH/docker-compose.yml
- rsync -rav -e ssh ./build/ $SSH_CREDENTIALS_SMART_CONTROL_SERVER:/$SMART_CONTROL_PATH/public/
- ssh -p22 $SSH_CREDENTIALS_SMART_CONTROL_SERVER "cd $SMART_CONTROL_PATH && docker compose up -d --force-recreate"
environment:
name: smart-control
url: https://dss.smart-control.inowas.com
only:
- tags
build:training:
image: node:16
stage: build
script:
- yarn install --ignore-platform
- REACT_APP_VERSION=$(git describe --tags --always --dirty=+) REACT_APP_API_URL=https://api.training.inowas.com NODE_OPTIONS=--max_old_space_size=4096 yarn build
- VERSION=$(git describe --tags --always --dirty=+) && DATE=$(date +%Y-%m-%dT%H:%M:%S) && sed -i "s/@@__VERSION__@@/${VERSION}/g;s/@@__BUILT__@@/${DATE}/g" ./build/index.html
artifacts:
paths:
- build/
only:
- tags
deploy:training:
stage: deploy
dependencies:
- build:training
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- mkdir -p ~/.ssh
- eval $(ssh-agent -s)
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- apt-get install rsync -y
script:
- ssh -p22 $SSH_CREDENTIALS_TRAINING_SERVER "cd $TRAINING_PATH && docker compose down"
- ssh -p22 $SSH_CREDENTIALS_TRAINING_SERVER "cd $TRAINING_PATH && rm -rf public && mkdir -p public"
- scp -P22 ./infrastructure/docker-compose.yml $SSH_CREDENTIALS_TRAINING_SERVER:/$TRAINING_PATH/docker-compose.yml
- rsync -rav -e ssh ./build/ $SSH_CREDENTIALS_TRAINING_SERVER:/$TRAINING_PATH/public/
- ssh -p22 $SSH_CREDENTIALS_TRAINING_SERVER "cd $TRAINING_PATH && docker compose up -d --force-recreate"
environment:
name: training
url: https://training.inowas.com
only:
- tags
build:prod:
image: node:16
stage: build
script:
- yarn install --ignore-platform
- REACT_APP_VERSION=$(git describe --tags --always --dirty=+) REACT_APP_API_URL=https://api.dss.inowas.com NODE_OPTIONS=--max_old_space_size=4096 yarn build
- VERSION=$(git describe --tags --always --dirty=+) && DATE=$(date +%Y-%m-%dT%H:%M:%S) && sed -i "s/@@__VERSION__@@/${VERSION}/g;s/@@__BUILT__@@/${DATE}/g" ./build/index.html
artifacts:
paths:
- build/
only:
- tags
deploy:prod:staging:
stage: deploy
dependencies:
- build:prod
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- mkdir -p ~/.ssh
- eval $(ssh-agent -s)
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- apt-get install rsync -y
script:
- ssh -p22 $SSH_CREDENTIALS_STAGING_SERVER "cd $STAGING_PATH && docker compose down"
- ssh -p22 $SSH_CREDENTIALS_STAGING_SERVER "cd $STAGING_PATH && rm -rf public && mkdir -p public"
- scp -P22 ./infrastructure/docker-compose.yml $SSH_CREDENTIALS_STAGING_SERVER:/$STAGING_PATH/docker-compose.yml
- rsync -rav -e ssh ./build/ $SSH_CREDENTIALS_STAGING_SERVER:/$STAGING_PATH/public/
- ssh -p22 $SSH_CREDENTIALS_STAGING_SERVER "cd $STAGING_PATH && docker compose up -d --force-recreate"
environment:
name: staging
url: https://staging.inowas.com
only:
- tags
deploy:prod:production:
stage: deploy
dependencies:
- build:prod
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- mkdir -p ~/.ssh
- eval $(ssh-agent -s)
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- apt-get install rsync -y
script:
- ssh -p22 $SSH_CREDENTIALS_PRODUCTION_SERVER "cd $PRODUCTION_PATH && docker compose down"
- ssh -p22 $SSH_CREDENTIALS_PRODUCTION_SERVER "cd $PRODUCTION_PATH && rm -rf public && mkdir -p public"
- scp -P22 ./infrastructure/docker-compose.yml $SSH_CREDENTIALS_PRODUCTION_SERVER:/$PRODUCTION_PATH/docker-compose.yml
- rsync -rav -e ssh ./build/ $SSH_CREDENTIALS_PRODUCTION_SERVER:/$PRODUCTION_PATH/public/
- ssh -p22 $SSH_CREDENTIALS_PRODUCTION_SERVER "cd $PRODUCTION_PATH && docker compose up -d --force-recreate"
environment:
name: production
url: https://dss.inowas.com
when: manual
only:
- tags