Speed_Read_AI / Dockerfile
circulartext's picture
Update Dockerfile
1130934
raw
history blame
1.48 kB
# Use the base Docker image with necessary dependencies
FROM circulartextapp/spaceread as base
# Set the working directory to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY . /app
# Define the user ID in the environment variable USER_ID with a default value
ARG USER_ID=1000
ENV USER_ID=$USER_ID
# Check if the user already exists
RUN if id "$USER_ID" >/dev/null 2>&1; then \
echo "User with ID $USER_ID already exists."; \
else \
useradd -m -u "$USER_ID" user; \
fi
# Set appropriate permissions for the application directory
RUN chown -R user:user /app && chmod -R 755 /app
# Switch to the user for improved security
USER user
# Install build tools
RUN apt-get update && apt-get install -y build-essential
# Download and compile su-exec
RUN wget -O su-exec.c 'https://raw.githubusercontent.com/ncopa/su-exec/master/su-exec.c' && \
gcc -o su-exec su-exec.c
# Copy su-exec to /usr/sbin
RUN cp su-exec /usr/sbin
# Remove unnecessary build tools
RUN apt-get purge -y build-essential && apt-get autoremove -y
# Final image
FROM base
# Copy entrypoint.sh to /app
COPY entrypoint.sh /app/entrypoint.sh
# Change permissions using su-exec
RUN su-exec user chmod +x /app/entrypoint.sh
# Set the entrypoint script as executable
ENTRYPOINT ["/app/entrypoint.sh"]
# Default command to run if the user doesn't provide a command
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]