92 lines
1.7 KiB
Markdown
92 lines
1.7 KiB
Markdown
|
# Installation
|
||
|
|
||
|
First, install Python in version ≥ 3.9
|
||
|
|
||
|
There are several ways to run Juggl api.
|
||
|
|
||
|
- [Directly via virtual environment](#virtual-environment)
|
||
|
- [In an automatically managed docker container](#docker-compose)
|
||
|
- [In a manually created docker container](#manual-container)
|
||
|
|
||
|
## Virtual Environment
|
||
|
|
||
|
Go to the backend directory.
|
||
|
|
||
|
```bash
|
||
|
$ cd backend
|
||
|
```
|
||
|
|
||
|
Create virtual environment:
|
||
|
|
||
|
```bash
|
||
|
$ python -m venv/ ./venv/
|
||
|
```
|
||
|
|
||
|
Activate virtual environment (Linux):
|
||
|
|
||
|
```bash
|
||
|
$ source venv/bin/activate
|
||
|
```
|
||
|
|
||
|
Activate virtual environment (Windows):
|
||
|
|
||
|
```bash
|
||
|
$ .venv\Scripts\activate
|
||
|
```
|
||
|
|
||
|
Run `src/main.py`:
|
||
|
|
||
|
> Note: When executing, you must be in the `backend/` directory! Executing the program from another directory will
|
||
|
> fail, because Python then can not resolve imports correctly. Why? Don't know.
|
||
|
|
||
|
```bash
|
||
|
$ python src/main.py
|
||
|
```
|
||
|
|
||
|
## Docker
|
||
|
|
||
|
Install [Docker](https://docs.docker.com/get-docker/) and [Docker-Compose](https://docs.docker.com/compose/install/).
|
||
|
|
||
|
### Docker-compose
|
||
|
|
||
|
Automatically set up all dependencies, export ports and start container(s) with docker-compose.
|
||
|
|
||
|
Build composed container setup:
|
||
|
```bash
|
||
|
$ docker-compose build
|
||
|
```
|
||
|
|
||
|
Start and block terminal with output
|
||
|
```bash
|
||
|
$ docker-compose up
|
||
|
```
|
||
|
|
||
|
Start in background (as deamon)
|
||
|
```bash
|
||
|
$ docker-compose up -d
|
||
|
```
|
||
|
|
||
|
Stop all containers
|
||
|
```bash
|
||
|
$ docker-compose down
|
||
|
```
|
||
|
|
||
|
### Manual container
|
||
|
|
||
|
Build and execute the docker container manually.
|
||
|
|
||
|
#### Build container
|
||
|
|
||
|
```bash
|
||
|
docker build -t juggl-api .
|
||
|
```
|
||
|
|
||
|
#### Start container
|
||
|
|
||
|
Execute the previously bild container.
|
||
|
|
||
|
Don't forget to export the port from the container to your host system with `-p HOST_PORT:CONTAINER_PORT`.
|
||
|
|
||
|
```bash
|
||
|
docker run -p 8192:8192 juggl-api
|
||
|
```
|