|
|
|
WORKDIR /app |
|
|
|
|
|
COPY . /app |
|
|
|
|
|
ARG USER_ID=1000 |
|
ENV USER_ID=$USER_ID |
|
|
|
|
|
RUN if [ -z "$USER_ID" ]; then \ |
|
echo "User ID not provided. Using the default user ID 1000."; \ |
|
USER_ID=1000; \ |
|
fi && \ |
|
if id "$USER_ID" >/dev/null 2>&1; then \ |
|
echo "User with ID $USER_ID already exists."; \ |
|
else \ |
|
adduser --uid "$USER_ID" --disabled-password --gecos '' appuser; \ |
|
fi |
|
|
|
|
|
RUN chown -R appuser:appuser /app && chmod -R 755 /app |
|
|
|
|
|
RUN apt-get update && apt-get install -y gosu && rm -rf /var/lib/apt/lists/* |
|
|
|
|
|
COPY entrypoint.sh /usr/local/bin/entrypoint.sh |
|
RUN chmod +x /usr/local/bin/entrypoint.sh |
|
|
|
|
|
USER appuser |
|
|
|
|
|
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] |
|
|
|
|
|
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--reload"] |
|
|