juggl/backend/docs/installation.md

92 lines
1.6 KiB
Markdown
Raw Normal View History

2021-12-21 22:45:28 +01:00
# 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
```
2021-12-22 09:06:08 +01:00
Run inside `backend/`:
2021-12-21 22:45:28 +01:00
2021-12-22 09:06:08 +01:00
> Note the `-m` here. This causes python to execute the program as a module, not as a script, which would result in
> broken imports.
2021-12-21 22:45:28 +01:00
```bash
2021-12-22 09:06:08 +01:00
$ python -m src.main
2021-12-21 22:45:28 +01:00
```
## 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
```