Skip to content
Snippets Groups Projects
Commit 75792360 authored by Timo Koch's avatar Timo Koch
Browse files

Merge branch 'feature/continuous-deploy' into 'master'

continuous deployment flask and react

See merge request dumux-appl/dumux-web-app!38
parents 55253349 d6389fce
No related branches found
No related tags found
1 merge request!38continuous deployment flask and react
Pipeline #2985 passed with stages
variables:
GIT_STRATEGY: clone
image: node:14
stages:
- flask-deploy
- react-deploy
flask:
stage: flask-deploy
# ssh setup
# variant of https://docs.gitlab.com/ee/ci/ssh_keys/README.html
before_script:
- eval $(ssh-agent -s)
- echo -e $backendkey | ssh-add -
- umask 0022
- mkdir ~/.ssh
- mv $hostkeyfile ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
script:
- scp $backendssh:continuous-deployment/services/server/flask-backend/gunicorn.log .
- ssh $backendssh "sudo /usr/bin/journalctl _SYSTEMD_UNIT=dumux-web-app.service" | tail -15000 | gzip -c > dumux-web-app.service.log.gz
- scp cd-setup/setup.sh $backendssh:setup-continuous-deployment.sh
- ssh $backendssh "chmod +x setup-continuous-deployment.sh && ./setup-continuous-deployment.sh"
- ssh-add -D # remove ssh-key from memory
artifacts:
expire_in: 1 days
when: always
paths:
# save previous logfiles, todo put in a different stage
- gunicorn.log
- dumux-web-app.service.log.gz
only:
- feature/continuous-deploy
- master
pages:
stage: react-deploy
script:
- umask 0022
- cd services/client/react-frontend
- echo "REACT_APP_SERVER_URL=https://dumux.org" > .env.production
- echo "REACT_APP_SERVER_WEB_SOCKET_URL=$backendurl" >> .env.production
- echo "REACT_APP_API_BASE_URL=/web-app/api" >>.env.production
- 'sed -i 3a\"homepage\":\ \"/web-app\", package.json'
- npm install
- CI="false" npm run build
- chmod -R go-w build
- cp -a --link build ../../../public
artifacts:
expire_in: 1 days
when: always
paths:
- public
- services/client/react-frontend/.env.production
- services/client/react-frontend/package.json
only:
- feature/continuous-deploy
- master
#!/bin/bash
set -eu # exit on error
set -x # show commands
# not implemented is to have backup/restore of the previous installation on fail of setup
rm -rf continuous-deployment || true
git clone https://git.iws.uni-stuttgart.de/dumux-appl/dumux-web-app.git continuous-deployment
cd continuous-deployment
# checkout a certain version; note this is only for the backend not necessarily synchronized with frontend
# git checkout ee07ab7a1ba924cdb60dd054b392bd2918ad3967
# make the setup
cd services/server/flask-backend
python -m venv venv
source venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install gunicorn
# emit gunicorn-script used by systemd script
cat <<- EOF > gunicorn.cmdline.sh
#!/bin/bash
source ./venv/bin/activate
export FLASK_ENV=production
export FLASK_APP_BASE_URL=/web-app
export FLASK_APP_SIMULATIONS_CONFIG=simulations.json
# have log file and stdout for journald
gunicorn -b "0.0.0.0:5000" --proxy-allow-from="*" --log-level debug --log-file=- --worker-tmp-dir /dev/shm --worker-class eventlet --workers 1 --threads 2 wsgi:application |& tee gunicorn.log
EOF
chmod +x gunicorn.cmdline.sh
# restart the service
sudo /bin/systemctl restart dumux-web-app
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment