-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (42 loc) · 1.4 KB
/
Dockerfile
File metadata and controls
51 lines (42 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
ARG BASE_IMAGE=python:3.10-slim-bullseye
FROM ${BASE_IMAGE}
# Keep Python output unbuffered and don't write .pyc files
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /app
# Install minimal system dependencies needed for building Python packages and git
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
git \
curl \
ca-certificates \
cmake \
pkg-config \
libsndfile1 \
libgomp1 \
libssl-dev \
libffi-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy dependency manifests first to leverage Docker layer caching
COPY pyproject.toml poetry.lock* /app/
# Install Poetry if pyproject exists and install dependencies. If no pyproject, skip.
RUN if [ -f pyproject.toml ]; then \
pip install --no-cache-dir poetry && \
poetry config virtualenvs.create false && \
poetry install --no-dev --no-interaction --no-ansi; \
elif [ -f requirements.txt ]; then \
pip install --no-cache-dir -r requirements.txt; \
else \
echo "No pyproject.toml or requirements.txt found, skipping dependency install"; \
fi
# Copy the rest of the project
COPY --chown=appuser:appuser . /app
# Create a non-root user for better security (optional)
ARG UID=1000
RUN useradd -m -u $UID appuser || true
USER appuser
EXPOSE 8000 8888
# Default command; override in compose or docker run if needed
ENTRYPOINT ["/app/run.sh"]
CMD ["help"]