Speed up backend image build and fix Debian 12 ODBC setup.
Use libreoffice-nogui on bookworm, gpg keyring for msodbcsql18, and BuildKit apt/pip caches.
Co-authored-by: Cursor <cursoragent@cursor.com>
(cherry picked from commit 844eb30747)
This commit is contained in:
1 parent
8c877e871a
commit
fed26821b7
3 files changed
+21
-12
No files matched your search
+16
-10
@@ -1,4 +1,5 @@
|
||||
ARG PYTHON_BASE_IMAGE=python:3.12-slim
|
||||
# syntax=docker/dockerfile:1.4
|
||||
ARG PYTHON_BASE_IMAGE=python:3.12-slim-bookworm
|
||||
FROM ${PYTHON_BASE_IMAGE}
|
||||
|
||||
ARG APT_MIRROR=https://mirrors.aliyun.com
|
||||
@@ -7,7 +8,9 @@ ARG PIP_EXTRA_INDEX_URL
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN set -eux; \
|
||||
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
||||
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; \
|
||||
@@ -16,26 +19,30 @@ RUN set -eux; \
|
||||
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 \
|
||||
apt-get update && apt-get install -y --no-install-recommends \
|
||||
libgl1 \
|
||||
libglib2.0-0 \
|
||||
libxcb1 \
|
||||
libx11-6 \
|
||||
libxext6 \
|
||||
libreoffice \
|
||||
libreoffice-nogui \
|
||||
fonts-noto-cjk \
|
||||
curl \
|
||||
gnupg2 \
|
||||
ca-certificates \
|
||||
gnupg \
|
||||
unixodbc-dev \
|
||||
&& curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
|
||||
&& curl https://packages.microsoft.com/config/debian/12/prod.list > /etc/apt/sources.list.d/mssql-release.list \
|
||||
&& install -d -m 0755 /etc/apt/keyrings \
|
||||
&& curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /etc/apt/keyrings/microsoft-prod.gpg \
|
||||
&& chmod a+r /etc/apt/keyrings/microsoft-prod.gpg \
|
||||
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/microsoft-prod.gpg] https://packages.microsoft.com/debian/12/prod bookworm main" > /etc/apt/sources.list.d/mssql-release.list \
|
||||
&& apt-get update \
|
||||
&& ACCEPT_EULA=Y apt-get install -y msodbcsql18 \
|
||||
&& ACCEPT_EULA=Y apt-get install -y --no-install-recommends msodbcsql18 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install Python dependencies
|
||||
COPY backend/requirements.txt .
|
||||
RUN set -eux; \
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
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}"; \
|
||||
@@ -62,4 +69,3 @@ EXPOSE 5000
|
||||
# Start Gunicorn
|
||||
# Using the config file we created earlier
|
||||
CMD ["gunicorn", "-c", "deploy/gunicorn_config.py", "run:app"]
|
||||
|
||||
Reference in new issue
Block a user