Fix ml-service volume permissions
This commit is contained in:
parent
7af1c75c56
commit
e446e3e563
2 changed files with 21 additions and 2 deletions
|
|
@ -6,6 +6,7 @@ RUN apt-get update && apt-get install -y \
|
||||||
wget \
|
wget \
|
||||||
curl \
|
curl \
|
||||||
libpq-dev \
|
libpq-dev \
|
||||||
|
gosu \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
RUN wget https://github.com/ta-lib/ta-lib/releases/download/v0.6.4/ta-lib_0.6.4_amd64.deb \
|
RUN wget https://github.com/ta-lib/ta-lib/releases/download/v0.6.4/ta-lib_0.6.4_amd64.deb \
|
||||||
|
|
@ -25,6 +26,10 @@ RUN pip install --no-cache-dir --upgrade pip && \
|
||||||
# Copy application code
|
# Copy application code
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
# Entrypoint to fix volume permissions before dropping privileges
|
||||||
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
# Expose port for FastAPI
|
# Expose port for FastAPI
|
||||||
EXPOSE 8001
|
EXPOSE 8001
|
||||||
|
|
||||||
|
|
@ -33,8 +38,9 @@ RUN useradd -r -s /bin/false appuser && \
|
||||||
mkdir -p /app/data/raw /app/data/processed && \
|
mkdir -p /app/data/raw /app/data/processed && \
|
||||||
chown -R appuser:appuser /app
|
chown -R appuser:appuser /app
|
||||||
|
|
||||||
# Switch to non-root user
|
# Run as root to fix volume permissions, then drop to appuser in entrypoint
|
||||||
USER appuser
|
USER root
|
||||||
|
|
||||||
# Run the inference server by default
|
# Run the inference server by default
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8001"]
|
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8001"]
|
||||||
|
|
|
||||||
13
services/ml/entrypoint.sh
Normal file
13
services/ml/entrypoint.sh
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
#!/bin/sh
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
# Fix permissions on mounted volumes so the non-root user can write.
|
||||||
|
# If the volume is root-owned (common on first run), chown it once.
|
||||||
|
if [ -d /app/data ]; then
|
||||||
|
chown -R appuser:appuser /app/data || true
|
||||||
|
fi
|
||||||
|
if [ -d /app/mlruns ]; then
|
||||||
|
chown -R appuser:appuser /app/mlruns || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec gosu appuser "$@"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue