initial commit

This commit is contained in:
straitz 2025-08-15 00:46:18 +09:00
commit c6961c03c3
33 changed files with 1782 additions and 0 deletions

76
Dockerfile Normal file
View file

@ -0,0 +1,76 @@
FROM python:3.13-slim AS builder
RUN mkdir /www
WORKDIR /www
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# RUN apt-get update && apt-get install -y --no-install-recommends \
# libpq-dev \
# gcc \
# g++ \
# libffi-dev \
# libssl-dev \
# libxml2-dev \
# libxslt1-dev \
# zlib1g-dev \
# libjpeg-dev \
# libfreetype6-dev && \
# rm -rf /var/lib/apt/lists/* && \
# apt-get clean && \
# apt-get autoclean
RUN pip install --upgrade pip
COPY requirements.txt /www/
RUN pip install --no-cache-dir -r requirements.txt
COPY requirements-prod.txt /www/
RUN pip install --no-cache-dir -r requirements-prod.txt
# Stage 2: Production stage
FROM python:3.13-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
libpq-dev \
libssl-dev \
gettext && \
apt-get clean && \
apt-get autoclean
RUN useradd -m -r wwwuser && \
mkdir /www && \
chown -R wwwuser /www
# Copy the Python dependencies from the builder stage
COPY --from=builder /usr/local/lib/python3.13/site-packages/ /usr/local/lib/python3.13/site-packages/
COPY --from=builder /usr/local/bin/ /usr/local/bin/
# Set the working directory
WORKDIR /www
# Copy application code
COPY --chown=wwwuser:wwwuser . .
RUN chmod +x /www/entrypoint.sh && \
chmod +x /www/manage.py
RUN mkdir -p /static && \
mkdir -p /media && \
chown -R wwwuser:wwwuser /static && \
chown -R wwwuser:wwwuser /media
# Set environment variables to optimize Python
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Switch to non-root user
USER wwwuser
# Expose the application port
EXPOSE 8000
# Run Djangos development server
CMD ["/www/entrypoint.sh"]