53 lines
1.7 KiB
Plaintext
53 lines
1.7 KiB
Plaintext
ARG PYTHON_BASE_IMAGE=python:3.12-slim
|
|
FROM ${PYTHON_BASE_IMAGE}
|
|
|
|
ARG APT_MIRROR=https://mirrors.aliyun.com
|
|
ARG PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple
|
|
ARG PIP_EXTRA_INDEX_URL
|
|
|
|
WORKDIR /app
|
|
|
|
RUN set -eux; \
|
|
if [ -f /etc/apt/sources.list.d/debian.sources ]; then \
|
|
sed -i "s|http://deb.debian.org/debian|${APT_MIRROR}/debian|g" /etc/apt/sources.list.d/debian.sources; \
|
|
sed -i "s|http://deb.debian.org/debian-security|${APT_MIRROR}/debian-security|g" /etc/apt/sources.list.d/debian.sources; \
|
|
fi; \
|
|
if [ -f /etc/apt/sources.list ]; then \
|
|
sed -i "s|http://deb.debian.org/debian|${APT_MIRROR}/debian|g" /etc/apt/sources.list; \
|
|
sed -i "s|http://deb.debian.org/debian-security|${APT_MIRROR}/debian-security|g" /etc/apt/sources.list; \
|
|
fi; \
|
|
apt-get update && apt-get install -y \
|
|
libgl1 \
|
|
libglib2.0-0 \
|
|
libxcb1 \
|
|
libx11-6 \
|
|
libxext6 \
|
|
libreoffice \
|
|
fonts-noto-cjk \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Install Python dependencies
|
|
COPY requirements.txt .
|
|
RUN set -eux; \
|
|
PIP_ARGS="--no-cache-dir --retries 10 --timeout 60"; \
|
|
if [ -n "${PIP_INDEX_URL:-}" ]; then \
|
|
PIP_ARGS="$PIP_ARGS --index-url ${PIP_INDEX_URL}"; \
|
|
fi; \
|
|
if [ -n "${PIP_EXTRA_INDEX_URL:-}" ]; then \
|
|
PIP_ARGS="$PIP_ARGS --extra-index-url ${PIP_EXTRA_INDEX_URL}"; \
|
|
fi; \
|
|
pip install $PIP_ARGS -r requirements.txt && \
|
|
pip uninstall -y opencv-python && \
|
|
pip install $PIP_ARGS opencv-python-headless && \
|
|
python -c "import networkx, openpyxl"
|
|
|
|
# Copy application code
|
|
COPY . .
|
|
|
|
# Expose port 5000
|
|
EXPOSE 5000
|
|
|
|
# Start Gunicorn
|
|
# Using the config file we created earlier
|
|
CMD ["gunicorn", "-c", "deploy/gunicorn_config.py", "run:app"]
|