92 lines
No EOL
1.6 KiB
Markdown
92 lines
No EOL
1.6 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 inside `backend/`:
|
|
|
|
> Note the `-m` here. This causes python to execute the program as a module, not as a script, which would result in
|
|
> broken imports.
|
|
|
|
```bash
|
|
$ python -m src.main
|
|
```
|
|
|
|
## 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
|
|
``` |