Speed_Read_AI / Dockerfile
circulartext's picture
Create Dockerfile
91a68c0
raw
history blame
1.45 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 username in the environment variable USERNAME with a default value
ARG USERNAME=default_user
ENV USERNAME=$USERNAME
# Check if the user already exists
RUN if id "$USERNAME" >/dev/null 2>&1; then \
echo "User $USERNAME already exists."; \
else \
useradd -m -u 1000 -s /bin/bash "$USERNAME"; \
fi
# Set appropriate permissions for the application directory
RUN chown -R "$USERNAME":"$USERNAME" /app && chmod -R 755 /app
# Switch to the user for improved security
USER "$USERNAME"
# Intermediate image with additional packages
FROM debian:bullseye-slim as packages
# Install gosu using apt-get
RUN apt-get update && apt-get install -y gosu && rm -rf /var/lib/apt/lists/*
# Final image
FROM base
# Copy gosu from the packages image
COPY --from=packages /usr/sbin/gosu /usr/sbin/gosu
# Set the entrypoint script as executable
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
# Define the entrypoint script to handle user creation and application startup
ENTRYPOINT ["/usr/local/bin/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"]