To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit a23da0fe authored by Alexander Dietmüller's avatar Alexander Dietmüller
Browse files

Update CI and README (no manual build of backend image anymore)

The pipeline can now build and deploy!
parent 136defe9
stages:
- test
- build
- deploy
frontend_eslint:
stage: test
image: node:latest
before_script:
- cd ./Frontend
- npm install
- cd ..
- cd ./Frontend
- npm install
- cd ..
when: always
script:
......@@ -11,7 +17,8 @@ frontend_eslint:
- npm run lint
- cd ..
backend:
backend_tests:
stage: test
image: python:alpine
services:
- name: bitnami/mongodb:latest
......@@ -24,9 +31,59 @@ backend:
MONGODB_PASSWORD: pvk_pass
before_script:
- pip install tox
- pip install tox
script:
- cd ./Backend
- tox
- cd ..
backend_build_master:
stage: build
image: docker:latest
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE_BACKEND" ./Backend/
- docker push "$CI_REGISTRY_IMAGE_BACKEND"
only:
- master
backend_build:
stage: build
image: docker:latest
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE_BACKEND:$CI_COMMIT_REF_SLUG" ./Backend/
- docker push "$CI_REGISTRY_IMAGE_BACKEND:$CI_COMMIT_REF_SLUG"
except:
- master
backend_deploy:
stage: deploy
image: jaromirpufler/docker-openssh-client
variables:
SSH_DEPLOY_KEY: $DEPLOY_PRIVATE_KEY
script:
- ssh $DEPLOY_HOST "docker pull $CI_REGISTRY_IMAGE_BACKEND; docker service update --force $DEPLOY_SERVICE_BACKEND;"
only:
- master
# There is no production server yet
# backend_deploy_master:
......@@ -11,7 +11,7 @@ from datetime import datetime as dt, timedelta
import requests
AMIVAPI_DEV_URL = "https://amiv-api.ethz.ch"
PVK_DEV_URL = 'http://localhost:8080' # 'http://pvk-api-dev.amiv.ethz.ch'
PVK_DEV_URL = 'http://pvk-api-dev.amiv.ethz.ch'
DATE_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
ASSISTANTS = ['pablo', 'assi', 'anon', 'mongo']
......@@ -34,6 +34,7 @@ def post(resource, data, token):
response = requests.post('%s/%s' % (PVK_DEV_URL, resource),
json=data,
headers={'Authorization': token})
print(response)
data = response.json()
if response.status_code != 201:
......
......@@ -6,50 +6,6 @@ A new AMIV PVK tool using Eve and authenticating users with AMIVAPI.
WIP.
### Starting A Local Backend for Development
Using Docker, you can quickly set up a backend with demo data to focus on
frontend development. Here's how:
1. [Install Docker](https://www.docker.com/community-edition#/download)
2. You need MongoDB. Luckily, you can just use Docker for that, too.
(It's one long command, make sure to copy everything to your command line)
```bash
docker run --name mongodb -d -p 27017 \
-e MONGODB_DATABASE="pvk" \
-e MONGODB_USERNAME="pvkuser" \
-e MONGODB_PASSWORD="pvkpass" \
bitnami/mongodb:latest
```
The environment variables specified with `-e` make sure that the db and user
are created
3. Build and start the dev-container. (Two commands this time)
Adjust the path `./Backend` at the end as needed so it points to the
`backend` directory.
```bash
docker build -t pvk ./Backend/
```
```bash
docker run --name pvk -d -p 80:80 \
--link mongodb \
-e MONGO_HOST="mongodb" \
pvk
```
The `--link` and `-e` make sure the backend can access the db container.
And now the backend is available at port 80, ready to use!
Use the commands `docker start pvk` / `docker stop pvk` and
`docker start mongodb` / `docker stop mongodb` to control your containers.
## Backend
The backend is implemented using [Eve](http://python-eve.org), a python
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment