Compare commits

...

2 Commits
master ... test

Author SHA1 Message Date
Jukoga c37470a53d redone the docker for testing 2024-08-12 23:37:55 +02:00
Jukoga 230e85d3d0 redone the docker for testing 2024-08-12 23:18:42 +02:00
4 changed files with 39 additions and 44 deletions

View File

@ -29,7 +29,7 @@ load_dotenv()
SECRET_KEY = os.getenv('SECRET_KEY')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
DEBUG = True
ALLOWED_HOSTS = ['localhost', '127.0.0.1', 'beyond-heroes.com', 'www.beyond-heroes.com']

View File

@ -1,34 +1,12 @@
# Use an official Python runtime as a parent image
FROM python:3.11-slim
# Use the official MariaDB base image
FROM mariadb:latest
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV MARIADB_ROOT_PASSWORD=DB_ROOTPW
ENV MARIADB_ROOT_HOST=%
ENV MARIADB_DATABASE=DBNAME
ENV MARIADB_USER=DB_USER
ENV MARIADB_PASSWORD=DB_PASSWORD
# Set working directory
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libpq-dev \
default-libmysqlclient-dev \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies
COPY requirements.txt /app/
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install gunicorn
# Copy project files
COPY . /app/
# Expose the port on which the application will run
EXPOSE 3030
# Define environment variable for Gunicorn
ENV GUNICORN_CMD_ARGS="--bind 0.0.0.0:3030"
# Run Gunicorn server with your Django application
CMD ["gunicorn", "BH.wsgi:application"]
# Expose the MariaDB port
EXPOSE 3306

17
TestInstructions.md Normal file
View File

@ -0,0 +1,17 @@
First of change the Env variables in the .env and the docker-compose.yml file to your own values.
Then create the docker container and run it with the following command:
```bash
docker-compose up --build
```
This starts the Database \
Then run the following command to create the database tables:
```bash
python manage.py migrate
python manage.py migrate --run-syncdb
```
At last, run the following command to start the server:
```bash
python manage.py runserver 3030
```

View File

@ -1,15 +1,15 @@
version: '3.8'
services:
django:
mariadb:
build: .
env_file:
- .env
volumes:
- .:/app
container_name: mariadb
restart: unless-stopped
environment:
MARIADB_ROOT_PASSWORD: 'DB_ROOTPW'
MARIADB_ROOT_HOST: '%'
MARIADB_DATABASE: 'DBNAME'
MARIADB_USER: 'DB_USER'
MARIADB_PASSWORD: 'DB_PASSWORD'
ports:
- "3030:3030"
network_mode: "host"
command: >
sh -c "python manage.py makemigrations blog --noinput &&
python manage.py migrate --noinput &&
python manage.py collectstatic --noinput &&
gunicorn BH.wsgi:application --bind 0.0.0.0:3030 --workers ${GUNICORN_WORKERS:-3}"
- "3306:3306"