Files
links/Dockerfile
T
2024-09-08 23:03:58 +10:00

48 lines
1.1 KiB
Docker

# Use an official Python runtime as a parent image
FROM python:3.12-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV DJANGO_SETTINGS_MODULE url_manager.settings
# Set work directory
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
nodejs \
npm \
gettext \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies
COPY requirements.txt /app/
RUN pip install --upgrade pip && pip install -r requirements.txt
# Copy project
COPY . /app/
# Install Tailwind CSS dependencies
RUN python manage.py tailwind install
# Build Tailwind CSS
RUN python manage.py tailwind build
# Collect static files
RUN python manage.py collectstatic --noinput
# Compile translation messages
RUN python manage.py compilemessages --locale=zh_Hans
# Create data directory for SQLite database
RUN mkdir -p /app/data && chmod 777 /app/data
ENV PYTHONPATH=/app
# Expose port 8000
EXPOSE 8000
# Run the application
CMD ["gunicorn", "--chdir", "/app", "url_manager.wsgi:application", "--bind", "0.0.0.0:8000"]