forked from danielgatis/rembg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
36 lines (27 loc) · 1011 Bytes
/
Dockerfile
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
# Use the official Python slim image as a base image
FROM python:3.10-slim
# Set the working directory
WORKDIR /home/appuser
# Install pip and system dependencies in one layer to leverage caching
RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential && \
pip install --upgrade pip && \
rm -rf /var/lib/apt/lists/*
# Copy the rest of the application code
COPY . .
# Install the application
RUN pip install --no-cache-dir ".[cli]"
# Create a non-root user and group with specific IDs, and give permissions
RUN groupadd -g 1001 appgroup && \
useradd -u 1001 -g appgroup -m appuser && \
chown -R appuser:appgroup /home/appuser
# Set the Numba cache directory environment variable
ENV NUMBA_CACHE_DIR=/home/appuser/numba_cache
ENV TMPDIR=/home/appuser/tmp
ENV GRADIO_FLAGGING_DIR=/home/appuser/flagged
# Expose the port the app runs on
EXPOSE 7000
# Switch to the non-root user
USER 1001
# Define the entrypoint and default command
ENTRYPOINT ["rembg", "s"]