image-ranker icon indicating copy to clipboard operation
image-ranker copied to clipboard

Docker Image

Open Albirex88 opened this issue 9 months ago β€’ 4 comments

I would like to request, if there is a possibility to create a docker image for this project. Having trouble building it and getting a path mapped to load the images.

Albirex88 avatar Mar 28 '25 19:03 Albirex88

Thank you for the feedback! If you have any specific error messages, I might be able to help you debug this. Also, if you are using MacOS, there is currently a seperate branch specifically for that operating system due to bugs in the past which are resolved there.

But I think you make a good point. A docker image seems useful so I am leaving this note here for me to add later:

# Use an official Python runtime as a parent image
FROM python:3.8-slim

# Set the working directory in the container
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . /app

# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# Make port 5000 available to the world outside this container
EXPOSE 5000

# Define environment variable
ENV IMAGE_DIR=/images

# Run app.py when the container launches
CMD ["python", "app.py"]

QuentinWach avatar Mar 28 '25 20:03 QuentinWach

The main issue I could not figure out, is connected to the way the folder is selected, as the webpage opens my file browser. The container runs on my debian server and I would need it to use a folder from a volume mount. I guess, there would need to be an option to set a fixed folder, instead of using the file browser. Hope this makes sense.

I actually had to use the seperate branch to get the image running on debian.

Here is the Dockerfile, that works in general (not really an expert, so not sure how good it is)

# Use a lightweight Python image
FROM python:3.10-slim

# Set the working directory
WORKDIR /app

# Install system dependencies (including Tkinter and virtual display tools)
RUN apt-get update && apt-get install -y \
    build-essential \
    python3-dev \
    python3-tk \
    tcl \
    xvfb \
    && rm -rf /var/lib/apt/lists/*

# Install required Python packages
RUN pip install --no-cache-dir flask trueskill

RUN mkdir /images

# Copy the application files
COPY . .

# Set environment variables
ENV FLASK_APP=app
ENV FLASK_ENV=production
ENV DISPLAY=:99  
# Set virtual display for Tkinter

# Start the virtual display and then run the Flask app
CMD ["bash", "-c", "Xvfb :99 -screen 0 1024x768x16 & flask run --host=0.0.0.0 --port=5000"]

Albirex88 avatar Mar 28 '25 20:03 Albirex88

Thanks for letting me know. :) Will need to merge those two branches, for sure, and think about adding proper docker support.

QuentinWach avatar Mar 28 '25 22:03 QuentinWach

I have found a way earlier to get images to be displayed in the container. I mapped a volume to /imageranker which had the images for ranking and on the PC using the frontend I also had a folder imageranker with the images. This triggered the container to load the images.

I suppose there needs to be an option to set a fixed folder as the source and a "refresh" button to scan the configured folder.

Albirex88 avatar Mar 28 '25 22:03 Albirex88