docker compose does something?

This commit is contained in:
Kiara Grouwstra 2022-01-03 20:24:36 +01:00
parent 5cc2a60621
commit 6bdcc7ab37
4 changed files with 32 additions and 26 deletions

View File

@ -1,16 +1,20 @@
# BIJ1 flyer app back-end
## Dependencies
## Prepare config files
- [Docker](https://docker.com/)
- [Python 3](https://www.python.org/)
- [R](https://r-project.org/)
```bash
cp backend/configs/mysql.txt backend/configs/mysql.cnf
sed 's/127.0.0.1/db/g' backend/configs/mysql.cnf > backend/configs/mysql.django.cnf
```
## Usage
Run the following commands:
Requirements:
- [Python 3](https://www.python.org/)
- [MySQL](https://www.mysql.com/) / [MariaDB](https://mariadb.org/)
Run the following commands, given a running MySQL:
```bash
docker run --name my-mysql --mount type=bind,src=$PWD/backend/configs/mysql.cnf,dst=/etc/my.cnf -d mysql
python3 -m venv ./env
source ./env/bin/activate
pip install -r requirements.txt
@ -20,8 +24,12 @@ python manage.py runserver
## Usage by Docker
Requirements:
- [Docker](https://docker.com/)
```bash
docker compose up
docker exec -it $(docker compose ps db --format json | jq '.[].Name' | sed -n 's/"//pg') /bin/bash -c 'mysql -uroot --password=password bij1 < /scripts/dump.sql'
```
## Data sources

View File

@ -1,6 +1,6 @@
[client]
DATABASE: 'bij1'
USER: 'root'
PASSWORD: 'password'
HOST: '127.0.0.1'
PORT: '3306'
database=bij1
user=root
password=password
host=127.0.0.1
port=3306

View File

@ -117,7 +117,7 @@ DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'OPTIONS': {
'read_default_file': './backend/configs/mysql.cnf'
'read_default_file': './backend/configs/mysql.django.cnf'
}
}
}

View File

@ -22,21 +22,19 @@ services:
volumes:
- my-db:/var/lib/mysql
- ./sql:/scripts
command: bash -c 'mysql -uroot --password="password" bij1 < /scripts/dump.sql; mysqld --user=root'
# python:
# image: python:slim-bullseye
# # restart: always
# depends_on:
# - mysql
# ports:
# - '8000:8000'
# expose:
# - '8000'
# volumes:
# - .:/app
# command:
# bash -c 'cd /app; pip install -r requirements.txt; python manage.py migrate; python manage.py runserver'
python:
image: python:slim-bullseye
# restart: always
depends_on:
- mysql
ports:
- '8000:8000'
expose:
- '8000'
volumes:
- .:/app
command: bash -c 'cd /app; pip install -r requirements.txt; python manage.py migrate; python manage.py runserver'
# Names our volume
volumes: