mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-10 19:52:53 +00:00
Merge branch '2-minimal-connector-and-app-should-be-part-of-the-minimal-deployment'
This commit is contained in:
38
README.md
38
README.md
@@ -20,14 +20,14 @@ This project shows a very fast way to deploy [backend](https://gitlab.com/openst
|
||||
an existing deployment of the TU Berlin).
|
||||
|
||||
|
||||
With a running backend and database you should be able to run the [app](https://gitlab.tubit.tu-berlin.de/stapps/app)
|
||||
With a running backend and database you should be able to run the [app](https://gitlab.com/openstapps/app)
|
||||
with your deployment.
|
||||
|
||||
# Step by step to your own deployment
|
||||
At first you need to install [docker](https://docs.docker.com/install/) and
|
||||
[docker-compose](https://docs.docker.com/compose/install/). Then clone or download this repository. To download the
|
||||
docker images from GitLab you have to be authenticated against GitLabs container registry. Please execute
|
||||
`docker login gitlab-registry.tubit.tu-berlin.de`. The requested credentials are the same as for GitLab.
|
||||
`docker login registry.gitlab.com`. The requested credentials are the same as for GitLab.
|
||||
`docker login` stores the credentials the users home directory. If you plan to execute docker commands only from root
|
||||
or via sudo you should run `docker login` with root or sudo as well.
|
||||
|
||||
@@ -74,7 +74,7 @@ docker-compose logs backend
|
||||
|
||||
The backend will find the database on `http://database:9200` inside the deployment network. As stated in the
|
||||
`docker-compose.yml` the backend will expose port 3000 on the host. You should be able to request the backend for it's
|
||||
configuration on http://localhost:3000.
|
||||
configuration on http://localhost:3000 (or http://MY-IP-ADDRESS:3000).
|
||||
|
||||
|
||||
Now you have a running backend that can be queried by the app. You could already try to the install the
|
||||
@@ -84,7 +84,7 @@ backend doesn't provide any data by now.
|
||||
There is no public deployment for the app version 2.0.0 by now. But you could copy some data from there.
|
||||
|
||||
To import some `SCPlace`'s you could run:
|
||||
```sh
|
||||
```shell
|
||||
docker-compose run --rm api copy --appVersion 2.0.0 place <url-of-public-deployment> http://backend:3000 20
|
||||
```
|
||||
This will copy data using the [api](https://gitlab.com/openstapps/api) from the deployment of the TU Berlin to your
|
||||
@@ -94,7 +94,7 @@ deployment.
|
||||
On Linux you can execute a simple shell script that will run you through
|
||||
steps above and copy some data in your deployment:
|
||||
|
||||
```sh
|
||||
```shell
|
||||
sh start.sh
|
||||
```
|
||||
|
||||
@@ -103,17 +103,37 @@ sh start.sh
|
||||
You now have your own deployment and can import some data from your university into the backend. To write your own
|
||||
program to import data you should checkout the [minimal-connector](https://gitlab.com/openstapps/minimal-connector/)
|
||||
This is a small program that shows the usage of the [api](https://gitlab.com/openstapps/api/) and imports some example
|
||||
data from TypeScript code. Feel free to copy the [minimal-connector](https://gitlab.com/openstapps/minimal-connector/)
|
||||
data from TypeScript code. Feel free to fork the [minimal-connector](https://gitlab.com/openstapps/minimal-connector/)
|
||||
and write your own connector with it.
|
||||
|
||||
## Add your connector
|
||||
You may want to integrate your connectors in the `docker-compose.yml` to
|
||||
deploy your whole StApps-backend-environment in a single command. Use the
|
||||
`systemd` directory in this project as an example of how to deploy
|
||||
your connector(s) and configure `systemd` services and timers.
|
||||
|
||||
The service will try to restart a named container. That means for successful
|
||||
execution the container needs to be started once before with the appropriate
|
||||
command.
|
||||
```shell
|
||||
docker-compose up minimal-connector
|
||||
```
|
||||
|
||||
To enable the service that runs the connector periodically execute:
|
||||
```shell
|
||||
systemctl --now enable /absolute/path/minimal-deployment/minimal-connector/minimal-connector.service /absolute/path/minimal-deployment/minimal-connector/minimal-connector.timer
|
||||
```
|
||||
This command will immediately start the service on execution.
|
||||
|
||||
## Round off your deployment with the [proxy](https://gitlab.com/openstapps/proxy)
|
||||
The backend is exposed on the port 3000 now. This means anyone can import data into your backend and you can only run
|
||||
one version of the backend at a time. Have a look at the [proxy](https://gitlab.com/openstapps/proxy/) to secure and
|
||||
round off your deployment. The proxy will allow you to run multiple deployments for different app version on one server
|
||||
and provide some static data like images for your university.
|
||||
round off your deployment. The proxy will add a layer of security, allowing you to run multiple deployments for
|
||||
different app version on one server and provide some static data like images for your university.
|
||||
|
||||
|
||||
## Explore docker capabilities
|
||||
Docker is a great tool with many great features. Have a look at the
|
||||
[docker cli documentation](https://docs.docker.com/engine/reference/commandline/cli/) or our
|
||||
[docker cheat sheet](https://gitlab.tubit.tu-berlin.de/stapps/projectmanagement/blob/master/DOCKER.md) to learn
|
||||
[docker cheat sheet](https://gitlab.com/openstapps/projectmanagement/blob/master/project-docs/DOCKER_CHEAT_SHEET.md) to learn
|
||||
more about it.
|
||||
|
||||
1
database/.gitignore
vendored
Normal file
1
database/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
nodes/
|
||||
@@ -1,4 +1,4 @@
|
||||
version: '2.1'
|
||||
version: '3.7'
|
||||
services:
|
||||
database:
|
||||
image: registry.gitlab.com/openstapps/database:master
|
||||
@@ -7,14 +7,9 @@ services:
|
||||
expose:
|
||||
- "9200"
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD", "nc", "-zv", "localhost", "9200"]
|
||||
interval: 5s
|
||||
timeout: 10s
|
||||
retries: 20
|
||||
|
||||
backend:
|
||||
image: registry.gitlab.com/openstapps/backend/default:master
|
||||
image: registry.gitlab.com/openstapps/backend/default:core-0.23
|
||||
environment:
|
||||
ES_PORT_9200_TCP_ADDR: database
|
||||
ES_PORT_9200_TCP_PORT: 9200
|
||||
@@ -30,11 +25,21 @@ services:
|
||||
- stapps.version=1.0.0
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
database:
|
||||
condition: service_healthy
|
||||
- database
|
||||
|
||||
api:
|
||||
image: registry.gitlab.com/openstapps/api/copy:v0.0.3
|
||||
image: registry.gitlab.com/openstapps/api/copy:core-0.23
|
||||
links:
|
||||
- "backend"
|
||||
|
||||
minimal-connector:
|
||||
image: registry.gitlab.com/openstapps/minimal-connector:core-0.23
|
||||
container_name: minimal-connector-0.23
|
||||
command: ["http://backend:3000", "minimal-connector", "f-u"]
|
||||
|
||||
app:
|
||||
image: registry.gitlab.com/openstapps/app/executable:core-0.23
|
||||
expose:
|
||||
- 8100
|
||||
ports:
|
||||
- 8100:8100
|
||||
|
||||
8
start.sh
8
start.sh
@@ -52,6 +52,14 @@ Useful commands:
|
||||
* In case you don't need the containers to be running anymore, you can also stop them using docker-compose command (example for database container):
|
||||
|
||||
$SUDO docker-compose stop database
|
||||
|
||||
* If you want to test the functionality of the "minimal-connector", use the following command.
|
||||
|
||||
$SUDO docker-compose up minimal-connector
|
||||
|
||||
* In case you want to see how the data looks like in the app, start its corresponding container.
|
||||
|
||||
$SUDO docker-compose up app
|
||||
EOF
|
||||
|
||||
read _
|
||||
|
||||
10
systemd/minimal-connector.service
Normal file
10
systemd/minimal-connector.service
Normal file
@@ -0,0 +1,10 @@
|
||||
[Unit]
|
||||
Description=Restarts the "minimal-connector-0.23" container
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
User=root
|
||||
ExecStart=/usr/bin/env docker restart minimal-connector-0.23
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
8
systemd/minimal-connector.timer
Normal file
8
systemd/minimal-connector.timer
Normal file
@@ -0,0 +1,8 @@
|
||||
[Unit]
|
||||
Description=Run the minimal-connector.service every 5 minutes. If you need other timer configurations, please refer to: https://wiki.archlinux.org/index.php/Systemd/Timers
|
||||
|
||||
[Timer]
|
||||
OnCalendar=*:0/5
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
Reference in New Issue
Block a user