add docker env for integration testing

This commit is contained in:
j3d1 2024-11-08 20:04:43 +01:00
parent 4d43eb5691
commit f9fa7e0390
6 changed files with 101 additions and 1 deletions

View file

@ -212,7 +212,7 @@ CHANNEL_LAYERS = {
'default': { 'default': {
'BACKEND': 'channels_redis.core.RedisChannelLayer', 'BACKEND': 'channels_redis.core.RedisChannelLayer',
'CONFIG': { 'CONFIG': {
'hosts': [('localhost', 6379)], 'hosts': [(os.getenv('REDIS_HOST', 'localhost'), 6379)],
}, },
} }

View file

@ -1,3 +1,4 @@
REDIS_HOST=localhost
DB_HOST=localhost DB_HOST=localhost
DB_PORT=3306 DB_PORT=3306
DB_NAME=c3lf_sys3 DB_NAME=c3lf_sys3

View file

@ -0,0 +1,11 @@
FROM python:3.11-bookworm
LABEL authors="lagertonne"
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
COPY requirements.prod.txt /code/
RUN apt update && apt install -y mariadb-client
RUN pip install -r requirements.prod.txt
RUN pip install mysqlclient
COPY .. /code/

View file

@ -0,0 +1,6 @@
FROM docker.io/node:22
RUN mkdir /web
WORKDIR /web
COPY package.json /web/
RUN npm install

View file

@ -0,0 +1,55 @@
services:
redis:
image: redis
ports:
- "6379:6379"
db:
image: mariadb
environment:
MARIADB_RANDOM_ROOT_PASSWORD: true
MARIADB_DATABASE: system3
MARIADB_USER: system3
MARIADB_PASSWORD: system3
volumes:
- mariadb_data:/var/lib/mysql
ports:
- "3306:3306"
core:
build:
context: ../../core
dockerfile: ../deploy/testing/Dockerfile.backend
command: bash -c 'python manage.py migrate && python /code/server.py'
environment:
- HTTP_HOST=core
- REDIS_HOST=redis
- DB_HOST=db
- DB_PORT=3306
- DB_NAME=system3
- DB_USER=system3
- DB_PASSWORD=system3
volumes:
- ../../core:/code
ports:
- "8000:8000"
depends_on:
- db
- redis
frontend:
build:
context: ../../web
dockerfile: ../deploy/testing/Dockerfile.frontend
command: npm run serve
volumes:
- ../../web:/web:ro
- /web/node_modules
- ./vue.config.js:/web/vue.config.js
ports:
- "8080:8080"
depends_on:
- core
volumes:
mariadb_data:

View file

@ -0,0 +1,27 @@
// vue.config.js
module.exports = {
devServer: {
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "*",
"Access-Control-Allow-Methods": "*"
},
proxy: {
'^/media/2': {
target: 'http://core:8000/',
},
'^/api/2': {
target: 'http://core:8000/',
},
'^/api/1': {
target: 'http://core:8000/',
},
'^/ws/2': {
target: 'http://core:8000/',
ws: true,
logLevel: 'debug',
},
}
}
}