mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-01-23 02:35:14 +00:00
Refactor DEBUG setting in settings.py and optimize Dockerfile build process
This commit is contained in:
parent
a38930b0c9
commit
f565e1fade
2 changed files with 42 additions and 31 deletions
|
|
@ -9,7 +9,12 @@ SECRET_KEY = 'REPLACE_ME_WITH_A_REAL_SECRET'
|
|||
REDIS_HOST = os.environ.get("REDIS_HOST", "localhost")
|
||||
REDIS_DB = os.environ.get("REDIS_DB", "0")
|
||||
|
||||
DEBUG = True
|
||||
# Set DEBUG to True for development, False for production
|
||||
if os.environ.get('DISPATCHARR_DEBUG', 'False').lower() == 'true':
|
||||
DEBUG = True
|
||||
else:
|
||||
DEBUG = False
|
||||
|
||||
ALLOWED_HOSTS = ["*"]
|
||||
|
||||
INSTALLED_APPS = [
|
||||
|
|
|
|||
|
|
@ -12,34 +12,36 @@ ENV PATH="/dispatcharrpy/bin:$PATH" \
|
|||
PYTHONUNBUFFERED=1 \
|
||||
DISPATCHARR_BUILD=1
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the application source code from the parent directory
|
||||
COPY . /app/
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
build-essential \
|
||||
curl \
|
||||
gcc \
|
||||
git \
|
||||
libpcre3 \
|
||||
libpcre3-dev \
|
||||
python3-dev \
|
||||
wget && \
|
||||
echo "=== setting up nodejs ===" && \
|
||||
curl -sL https://deb.nodesource.com/setup_23.x -o /tmp/nodesource_setup.sh && \
|
||||
bash /tmp/nodesource_setup.sh && \
|
||||
apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
nodejs && \
|
||||
build-essential \
|
||||
curl \
|
||||
gcc \
|
||||
git \
|
||||
libpcre3 \
|
||||
libpcre3-dev \
|
||||
python3-dev \
|
||||
wget && \
|
||||
python -m pip install virtualenv && \
|
||||
virtualenv /dispatcharrpy && \
|
||||
git clone -b ${BRANCH} ${REPO_URL} /app && \
|
||||
cd /app && \
|
||||
rm -rf .git && \
|
||||
cd /app && \
|
||||
pip install --no-cache-dir -r requirements.txt && \
|
||||
python manage.py collectstatic --noinput && \
|
||||
cd /app/frontend && \
|
||||
npm install --legacy-peer-deps && \
|
||||
npm run build && \
|
||||
find . -maxdepth 1 ! -name '.' ! -name 'dist' -exec rm -rf '{}' \;
|
||||
pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Use a dedicated Node.js stage for frontend building
|
||||
FROM node:20-slim AS frontend-builder
|
||||
WORKDIR /app/frontend
|
||||
COPY --from=builder /app /app
|
||||
RUN npm install --legacy-peer-deps && \
|
||||
npm run build
|
||||
|
||||
FROM python:3.13-slim
|
||||
|
||||
|
|
@ -51,20 +53,24 @@ ENV PATH="/dispatcharrpy/bin:$PATH" \
|
|||
# Copy the virtual environment and application from the builder stage
|
||||
COPY --from=builder /dispatcharrpy /dispatcharrpy
|
||||
COPY --from=builder /app /app
|
||||
COPY --from=frontend-builder /app/frontend /app/frontend
|
||||
|
||||
# Run collectstatic after frontend assets are copied
|
||||
RUN cd /app && python manage.py collectstatic --noinput
|
||||
|
||||
# Install base dependencies with memory optimization
|
||||
RUN apt-get update && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
||||
curl \
|
||||
ffmpeg \
|
||||
libpcre3 \
|
||||
libpq-dev \
|
||||
nginx \
|
||||
procps \
|
||||
streamlink \
|
||||
wget \
|
||||
gnupg2 \
|
||||
lsb-release && \
|
||||
curl \
|
||||
ffmpeg \
|
||||
libpcre3 \
|
||||
libpq-dev \
|
||||
nginx \
|
||||
procps \
|
||||
streamlink \
|
||||
wget \
|
||||
gnupg2 \
|
||||
lsb-release && \
|
||||
cp /app/docker/nginx.conf /etc/nginx/sites-enabled/default && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue