# Use a suitable base Docker image with necessary dependencies FROM circulartextapp/spaceread # 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 ARG USER_ID 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 # Install gosu (adjust the package manager based on your base image) RUN apk add --no-cache gosu # Set the entrypoint script as executable COPY entrypoint.sh /usr/local/bin/entrypoint.sh RUN chmod +x /usr/local/bin/entrypoint.sh # Switch to the user for improved security USER user # 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"]