Add Docker stuff
This commit is contained in:
12
.env.example
Normal file
12
.env.example
Normal file
@ -0,0 +1,12 @@
|
||||
SECRET_KEY=
|
||||
DEBUG=True
|
||||
ADMIN_EMAIL=
|
||||
EMAIL_HOST_USER=
|
||||
EMAIL_HOST_PASSWORD=
|
||||
REDIS_PASSWORD=
|
||||
REDIS_HOST=192.168.1.2
|
||||
POSTGRES_USER=
|
||||
POSTGRES_PASSWORD=
|
||||
POSTGRES_HOST=192.168.1.2
|
||||
POSTGRES_PORT=5433
|
||||
TUNNEL_TOKEN=
|
9
.vscode/settings.json
vendored
Normal file
9
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"cSpell.words": [
|
||||
"appendonly",
|
||||
"PGID",
|
||||
"PUID",
|
||||
"requirepass",
|
||||
"ttvdrops"
|
||||
]
|
||||
}
|
55
Dockerfile
Normal file
55
Dockerfile
Normal file
@ -0,0 +1,55 @@
|
||||
# Stage 1: Build the requirements.txt using Poetry
|
||||
FROM python:3.12-slim AS builder
|
||||
|
||||
# Set environment variables for Python
|
||||
ENV PYTHONDONTWRITEBYTECODE 1
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
ENV PATH="${PATH}:/root/.local/bin"
|
||||
|
||||
# Install system dependencies
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
curl \
|
||||
git \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install Poetry
|
||||
RUN curl -sSL https://install.python-poetry.org | python3 -
|
||||
|
||||
# Copy only the poetry.lock/pyproject.toml to leverage Docker cache
|
||||
WORKDIR /app
|
||||
COPY pyproject.toml poetry.lock /app/
|
||||
|
||||
# Install dependencies and create requirements.txt
|
||||
RUN poetry self add poetry-plugin-export && poetry export --format=requirements.txt --output=requirements.txt --only=main --without-hashes
|
||||
|
||||
# Stage 2: Install dependencies and run the Django application
|
||||
FROM python:3.12-slim AS runner
|
||||
|
||||
# Set environment variables for Python
|
||||
ENV PYTHONDONTWRITEBYTECODE 1
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
|
||||
# Install system dependencies
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
libpq-dev \
|
||||
git \
|
||||
netcat-openbsd \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy the generated requirements.txt from the builder stage
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/requirements.txt /app/
|
||||
|
||||
# Install application dependencies
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Copy the rest of the application code
|
||||
COPY . /app/
|
||||
|
||||
# The port the application will listen on
|
||||
EXPOSE 8000
|
||||
|
||||
# Run startup script
|
||||
CMD ["./docker-entrypoint.sh"]
|
74
docker-compose.yml
Normal file
74
docker-compose.yml
Normal file
@ -0,0 +1,74 @@
|
||||
services:
|
||||
# ttvdrops:
|
||||
# container_name: ttvdrops
|
||||
# image: ghcr.io/thelovinator1/ttvdrops:latest
|
||||
# restart: always
|
||||
# networks:
|
||||
# - ttvdrops_redis
|
||||
# - ttvdrops_db
|
||||
# - ttvdrops_web
|
||||
# environment:
|
||||
# - SECRET_KEY=${SECRET_KEY}
|
||||
# - DEBUG=${DEBUG}
|
||||
# - ADMIN_EMAIL=${ADMIN_EMAIL}
|
||||
# - EMAIL_HOST_USER=${EMAIL_HOST_USER}
|
||||
# - EMAIL_HOST_PASSWORD=${EMAIL_HOST_PASSWORD}
|
||||
# - REDIS_HOST=redis
|
||||
# - REDIS_PASSWORD=${REDIS_PASSWORD}
|
||||
# - POSTGRES_HOST=postgres
|
||||
# - POSTGRES_PORT=5432
|
||||
# - POSTGRES_DB=${POSTGRES_DB}
|
||||
# - POSTGRES_USER=${POSTGRES_USER}
|
||||
# - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||||
# volumes:
|
||||
# - /mnt/Fourteen/Docker/ttvdrops/staticfiles:/app/staticfiles
|
||||
web:
|
||||
container_name: ttvdrops_web
|
||||
image: lscr.io/linuxserver/nginx:latest
|
||||
restart: always
|
||||
environment:
|
||||
- PUID=1000
|
||||
- PGID=1000
|
||||
- TZ=Europe/Stockholm
|
||||
expose:
|
||||
- 80
|
||||
- 443
|
||||
volumes:
|
||||
- /mnt/Fourteen/Docker/ttvdrops/Nginx:/config
|
||||
networks:
|
||||
- ttvdrops_web
|
||||
redis:
|
||||
container_name: ttvdrops_redis
|
||||
image: redis:latest
|
||||
restart: always
|
||||
user: "1000:1000"
|
||||
ports:
|
||||
- 6380:6379
|
||||
command: /bin/sh -c 'redis-server --requirepass ${REDIS_PASSWORD} --appendonly yes'
|
||||
volumes:
|
||||
- /mnt/Fourteen/Docker/ttvdrops/Redis:/data
|
||||
networks:
|
||||
- ttvdrops_redis
|
||||
postgres:
|
||||
container_name: ttvdrops_postgres
|
||||
image: postgres:16
|
||||
# user: "1000:1000"
|
||||
ports:
|
||||
- 5433:5432
|
||||
restart: always
|
||||
environment:
|
||||
- POSTGRES_USER=${POSTGRES_USER}
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||||
- POSTGRES_DB=${POSTGRES_DB}
|
||||
volumes:
|
||||
- /mnt/Fourteen/Docker/ttvdrops/Postgres:/var/lib/postgresql/data
|
||||
networks:
|
||||
- ttvdrops_db
|
||||
|
||||
networks:
|
||||
ttvdrops_redis:
|
||||
driver: bridge
|
||||
ttvdrops_db:
|
||||
driver: bridge
|
||||
ttvdrops_web:
|
||||
driver: bridge
|
Reference in New Issue
Block a user