pythonflaskdockerfilerdkit

About a critical issue while building a Flask-based web app involves in the Docker desktop


I am writing here to seek for your help to the issue while building up a Flask-based web application in the Docker. It is chemical-related, so I need to import rdkit module, and I also need to use Docker to set up virtual worker machines to do some modeling as well. The first step is to run the docker composing yml file:

version: '2'
services:
    redis:
        image: redis
#        ports:
#            - "6379:6379"
        volumes:
            - ./redis:/usr/local/etc/redis
#        command: redis-server --include /usr/local/etc/redis/redis.conf

    toxpro:
        build: .
        # this is outlined here: https://docs.docker.com/compose/environment-variables/
        env_file:
            - docker-environment-do.env
        ports:
            - "80:5000"
        image: toxpro:lastest
        volumes:
            - ./instance/:/home/toxpro/instance
            - ./data/:/home/toxpro/data
        entrypoint: ["./boot.sh"]
        stdin_open: true
        tty: true

    worker:
        build: .
        env_file:
            - docker-environment-do.env
        depends_on:
            - redis
            - toxpro
        entrypoint: ["./boot_worker.sh"]
        volumes:
            - ./instance/:/home/toxpro/instance
            - ./data/:/home/toxpro/data

# this is necessary for the workers to
# share writing to the SQLite I believ
volumes:
  instance_vol:

Using the Docker file:

FROM python

RUN useradd toxpro

WORKDIR /home/toxpro

COPY requirements.txt requirements.txt
RUN python -m venv venv
RUN venv/bin/pip install -r requirements.txt

# netcat is a program
# necessary for troubleshooting
# the networking
RUN apt-get update && apt-get install -y netcat-traditional


COPY app app
RUN mkdir logs
RUN mkdir data
RUN mkdir instance # this is necessary for digital ocean

COPY boot.sh ./
RUN chmod +x boot.sh

COPY boot_worker.sh ./
RUN chmod +x boot_worker.sh

COPY boot_dashboard.sh ./
RUN chmod +x boot_dashboard.sh

RUN apt-get install libxrender1
ENV FLASK_APP app.py

RUN chown -R toxpro:toxpro ./
USER toxpro

EXPOSE 5000

#ENTRYPOINT ["./boot.sh"]

As well as the requirements.txt:

Flask==2.2
gunicorn==20.1.0
pandas==1.5.2
pip==22.3.1
plotly==5.9.0
rdkit==2022.09.2
flask-sqlalchemy==3.0.2
flask-login==0.6.2
flask-migrate==4.0.0
Flask-Mail==0.9.1
scikit-learn==1.2.0
redis==4.4.0
rq==1.11.1
PyJWT==2.6.0
numpy==1.23.2
requests==2.30.0

However, since the night of the day before yesterday (about 11:00PM CDT), when I tried to run this process, there's always an error reported while installing requirements.txt which never encountered before:

98.75 ERROR: Could not find a version that satisfies the requirement rdkit==2022.09.2 (from versions: none) 98.75 ERROR: No matching distribution found for rdkit==2022.09.2

failed to solve: process "/bin/sh -c venv/bin/pip install -r requirements.txt" did not complete successfully: exit code: 1 docker-compose process finished with exit code 17

I tried to modify the version after "rdkit==", reinstall pip and rdkit, as well as reinstall the whole environment for my application, but the problem was not able to be solved. Have anyone encountered this kind of problem before? Or had idea about what's happening? Feel free to have a view on my codes if necessary: ToxiVerse

I tried to modify the version after "rdkit==", reinstall pip and rdkit, as well as reinstall the whole environment for my application, but the problem was not able to be solved. Have anyone encountered this kind of problem before? Or had idea about what's happening? Feel free to have a view on my codes if necessary: ToxiVerse


Solution

  • You should set a specific python version in Dockerfile.

    Dockerfile

    FROM python:3.9
    
    RUN useradd toxpro
    
    WORKDIR /home/toxpro
    
    COPY requirements.txt requirements.txt
    RUN pip install -r requirements.txt
    
    # You don't have to use a virtual environment in docker.
    #RUN python -m venv venv
    #RUN venv/bin/pip install -r requirements.txt
    
    ...