Skip to content
Snippets Groups Projects
Commit 97f5c65d authored by Tim Repke's avatar Tim Repke
Browse files

add server deployment CI

parent a4b89fb3
No related branches found
No related tags found
1 merge request!14Server deployment
...@@ -23,6 +23,11 @@ cache: ...@@ -23,6 +23,11 @@ cache:
- .cache/pip - .cache/pip
- venv/ - venv/
stages:
- build
- test
- deploy
build-job: build-job:
stage: build stage: build
script: script:
...@@ -48,14 +53,26 @@ test-job2: ...@@ -48,14 +53,26 @@ test-job2:
- source venv/bin/activate - source venv/bin/activate
- mypy --config-file=pyproject.toml server - mypy --config-file=pyproject.toml server
deploy-to-production:
#pages: stage: deploy
# script: script:
# - pip install sphinx sphinx-rtd-theme - echo "Becoming 'nacsos' user"
# - cd doc ; make html - su - nacsos
# - mv build/html/ ../public/ - cd /home/nacsos/nacsos-core
# artifacts: - echo "Stopping NACSOS-core service"
# paths: - systemctl --user stop nacsos-core
# - public - echo "Dropping virtual environment"
# rules: - rm -rf venv
# - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - echo "Fetching updated source"
- git stash # "reset" softly by stashing (in case files changed)
- git pull origin production # pull from origin (production branch)
- echo "Creating new virtual environment"
- python3.10 -m venv venv
- source venv/bin/activate
- echo "Installing requirements"
- pip install -r requirements.txt
- echo "Exiting 'nacsos' user scope"
- echo "Starting NACSOS-core service"
- systemctl --user start nacsos-core
only:
- production
...@@ -3,6 +3,10 @@ This repository contains the core data management platform of NACSOS. ...@@ -3,6 +3,10 @@ This repository contains the core data management platform of NACSOS.
It accesses the database via the `nacsos-data` package and exposes the functionality via an API. It accesses the database via the `nacsos-data` package and exposes the functionality via an API.
It also serves the web frontend. It also serves the web frontend.
```
pg_dump -d nacsos_core -h localhost -U root -W -p 5432 > dump.sql
```
## Installation ## Installation
- Requires Python 3.10+, tested with Python 3.10.2 - Requires Python 3.10+, tested with Python 3.10.2
......
echo "Stopping NACSOS-core service"
syetemctl stop nacos-core
echo "Becoming 'nacsos' user"
su - nacsos
cd /home/nacsos/nacsos-core
echo "Dropping virtual environment"
rm -rf venv
echo "Fetching updated source"
# "reset" softly by stashing (in case files changed)
git stash
# pull from origin (production branch)
git pull origin production
echo "Creating new virtual environment"
python3.10 -m venv venv
source venv/bin/activate
echo "Installing requirements"
pip install -r requirements.txt
echo "Exiting 'nacsos' user scope"
exit
echo "Starting NACSOS-core service"
systemctl start nacsos-core
Postgres users:
```
nacsos (admin): $v5aCh$kGE9ybF@XtE*%CETA&4bXt8vu$NTZUxi*J@f%
nacsos_user (user): HqVxmmuJgPR#4dYL8m%32JLG$c#%kkwqoWB4vQay@Rbr
```
UNIX users:
```
username: nacsos
password: none
home at /home/nacsos
(not sudo, no extra groups)
```
## Systemd Setup
### NACSOS-core
Create `/.config/systemd/user/nacsos-core.service`
```
[Unit]
Description=NACSOS core server
After=network.target
[Service]
User=nacsos
WorkingDirectory=/home/nacsos/nacsos-core
LimitNOFILE=4096
ExecStart=/home/nacsos/nacsos-core/venv/bin/python -m hypercorn main:app --config=config/hypercorn-server.toml
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
```
```bash
sudo systemctl daemon-reload
sudo systemctl enable nacsos-core
sudo systemctl start nacsos-core
```
### NACSOS-pipes
Create `/etc/systemd/system/nacsos-pipes.service`
```
[Unit]
Description=NACSOS core server
After=network.target
[Service]
User=nacsos
WorkingDirectory=/home/nacsos/nacsos-core
LimitNOFILE=4096
ExecStart=/home/nacsos/nacsos-core/venv/bin/python -m hypercorn main:app --config=config/hypercorn-server.toml
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
```
\ No newline at end of file
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