mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-01-23 02:35:14 +00:00
Added AIO docker ability
This commit is contained in:
parent
6b857d3931
commit
bb4da18c56
6 changed files with 167 additions and 0 deletions
27
.dockerignore
Executable file
27
.dockerignore
Executable file
|
|
@ -0,0 +1,27 @@
|
|||
**/__pycache__
|
||||
**/.venv
|
||||
**/.classpath
|
||||
**/.dockerignore
|
||||
**/.env
|
||||
**/.git
|
||||
**/.gitignore
|
||||
**/.project
|
||||
**/.settings
|
||||
**/.toolstarget
|
||||
**/.vs
|
||||
**/.vscode
|
||||
**/*.*proj.user
|
||||
**/*.dbmdl
|
||||
**/*.jfm
|
||||
**/bin
|
||||
**/charts
|
||||
**/docker-compose*
|
||||
**/compose*
|
||||
**/Dockerfile*
|
||||
**/node_modules
|
||||
**/npm-debug.log
|
||||
**/obj
|
||||
**/secrets.dev.yaml
|
||||
**/values.dev.yaml
|
||||
LICENSE
|
||||
README.md
|
||||
0
.gitattributes
vendored
Normal file → Executable file
0
.gitattributes
vendored
Normal file → Executable file
3
.gitignore
vendored
Normal file → Executable file
3
.gitignore
vendored
Normal file → Executable file
|
|
@ -1,2 +1,5 @@
|
|||
.DS_Store
|
||||
__pycache__/
|
||||
**/__pycache__/
|
||||
.vscode/launch.json
|
||||
.vscode/tasks.json
|
||||
|
|
|
|||
5
.vscode/settings.json
vendored
Executable file
5
.vscode/settings.json
vendored
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"docker.imageBuildContextPath": "${workspaceFolder}"
|
||||
//"docker.imageBuildContextPath": "/MainPool/Main/Vital_Data/Scripts/Dispatcharr/Dispatcharr"
|
||||
|
||||
}
|
||||
45
docker/DockerfileAIO
Executable file
45
docker/DockerfileAIO
Executable file
|
|
@ -0,0 +1,45 @@
|
|||
FROM python:3.10-slim
|
||||
|
||||
# Add PostgreSQL repository
|
||||
RUN apt-get update && apt-get install -y wget gnupg2 && \
|
||||
echo "deb http://apt.postgresql.org/pub/repos/apt/ bookworm-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
|
||||
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
|
||||
|
||||
# Install required packages
|
||||
RUN apt-get update && apt-get install -y \
|
||||
ffmpeg \
|
||||
streamlink \
|
||||
vlc \
|
||||
libpq-dev \
|
||||
gcc \
|
||||
postgresql-14 \
|
||||
postgresql-contrib-14 \
|
||||
redis-server \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy requirements.txt from the parent directory
|
||||
COPY requirements.txt /app/
|
||||
|
||||
# Install Python dependencies
|
||||
RUN pip install --no-cache-dir -r /app/requirements.txt
|
||||
|
||||
# Copy the application source code from the parent directory
|
||||
COPY . /app/
|
||||
|
||||
# Set environment variables
|
||||
ENV DJANGO_SETTINGS_MODULE=dispatcharr.settings
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
|
||||
|
||||
# Copy the entrypoint script
|
||||
COPY docker/entrypoint.sh /app/entrypoint.sh
|
||||
RUN chmod +x /app/entrypoint.sh
|
||||
|
||||
# Expose the port
|
||||
EXPOSE 9191
|
||||
|
||||
# Command to run the startup script
|
||||
CMD ["/app/entrypoint.sh"]
|
||||
87
docker/entrypoint.sh
Executable file
87
docker/entrypoint.sh
Executable file
|
|
@ -0,0 +1,87 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Set PostgreSQL environment variables
|
||||
export POSTGRES_DB=${POSTGRES_DB:-dispatcharr}
|
||||
export POSTGRES_USER=${POSTGRES_USER:-dispatch}
|
||||
export POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-secret}
|
||||
export POSTGRES_HOST=${POSTGRES_HOST:-localhost}
|
||||
export POSTGRES_PORT=${POSTGRES_PORT:-5432}
|
||||
export PGDATA=${PGDATA:-/app/data/db}
|
||||
export PG_BINDIR="/usr/lib/postgresql/14/bin"
|
||||
|
||||
# Echo environment variables for debugging
|
||||
echo "POSTGRES_DB: $POSTGRES_DB"
|
||||
echo "POSTGRES_USER: $POSTGRES_USER"
|
||||
echo "POSTGRES_PASSWORD: $POSTGRES_PASSWORD"
|
||||
echo "POSTGRES_HOST: $POSTGRES_HOST"
|
||||
echo "POSTGRES_PORT: $POSTGRES_PORT"
|
||||
|
||||
# Create group if it doesn't exist
|
||||
if ! getent group "$PGID" >/dev/null 2>&1; then
|
||||
groupadd -g "$PGID" mygroup
|
||||
fi
|
||||
# Create user if it doesn't exist
|
||||
if ! getent passwd $PUID > /dev/null 2>&1; then
|
||||
useradd -u $PUID -g $PGID -m $POSTGRES_USER
|
||||
else
|
||||
existing_user=$(getent passwd $PUID | cut -d: -f1)
|
||||
if [ "$existing_user" != "$POSTGRES_USER" ]; then
|
||||
usermod -l $POSTGRES_USER -g $PGID "$existing_user"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Initialize PostgreSQL database
|
||||
if [ -z "$(ls -A "$PGDATA")" ]; then
|
||||
echo "Initializing PostgreSQL database..."
|
||||
mkdir -p "$PGDATA"
|
||||
chown -R postgres:postgres "$PGDATA"
|
||||
chmod 700 "$PGDATA"
|
||||
|
||||
# Initialize PostgreSQL
|
||||
su - postgres -c "$PG_BINDIR/initdb -D $PGDATA"
|
||||
# Configure PostgreSQL
|
||||
echo "host all all 0.0.0.0/0 md5" >> "$PGDATA/pg_hba.conf"
|
||||
echo "listen_addresses='*'" >> "$PGDATA/postgresql.conf"
|
||||
|
||||
fi
|
||||
|
||||
# Start PostgreSQL
|
||||
su - postgres -c "$PG_BINDIR/pg_ctl -D $PGDATA start -w -t 300 -o '-c port=${POSTGRES_PORT}'"
|
||||
|
||||
# Wait for PostgreSQL to be ready
|
||||
until su - postgres -c "$PG_BINDIR/pg_isready -h ${POSTGRES_HOST} -p ${POSTGRES_PORT}" >/dev/null 2>&1; do
|
||||
echo "Waiting for PostgreSQL to be ready..."
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# Setup database if needed
|
||||
if ! su - postgres -c "psql -p ${POSTGRES_PORT} -tAc \"SELECT 1 FROM pg_database WHERE datname = '$POSTGRES_DB';\"" | grep -q 1; then
|
||||
# Create PostgreSQL database
|
||||
su - postgres -c "createdb -p ${POSTGRES_PORT} ${POSTGRES_DB}"
|
||||
|
||||
# Create user, set ownership, and grant privileges
|
||||
su - postgres -c "psql -p ${POSTGRES_PORT} -d ${POSTGRES_DB}" <<EOF
|
||||
DO \$\$
|
||||
BEGIN
|
||||
IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = '$POSTGRES_USER') THEN
|
||||
CREATE ROLE $POSTGRES_USER WITH LOGIN PASSWORD '$POSTGRES_PASSWORD';
|
||||
END IF;
|
||||
END
|
||||
\$\$;
|
||||
EOF
|
||||
su postgres -c "$PG_BINDIR/psql -p ${POSTGRES_PORT} -c \"ALTER DATABASE ${POSTGRES_DB} OWNER TO $POSTGRES_USER;\""
|
||||
su postgres -c "$PG_BINDIR/psql -p ${POSTGRES_PORT} -c \"GRANT ALL PRIVILEGES ON DATABASE ${POSTGRES_DB} TO $POSTGRES_USER;\""
|
||||
fi
|
||||
|
||||
# Test PostgreSQL connection
|
||||
pg_isready -h $POSTGRES_HOST -p $POSTGRES_PORT -U $POSTGRES_USER
|
||||
|
||||
# Start Redis
|
||||
service redis-server start
|
||||
|
||||
# Run Django commands
|
||||
python manage.py collectstatic --noinput || true
|
||||
python manage.py migrate --noinput || true
|
||||
|
||||
# Start Gunicorn
|
||||
gunicorn --workers=4 --worker-class=gevent --timeout=300 --bind 0.0.0.0:9191 dispatcharr.wsgi:application
|
||||
Loading…
Add table
Add a link
Reference in a new issue