rethinkdb-dockerfiles icon indicating copy to clipboard operation
rethinkdb-dockerfiles copied to clipboard

Include python drivers in container

Open mishawakerman opened this issue 5 years ago • 8 comments

Is your feature request related to a problem? Please describe. After upgrading from version 2.3.6 → 2.4.0, I needed to rebuild some indexes but could not do so within/using the docker container. I tried running it within the container and got the following:

root@bb258af077c8:/data# rethinkdb index-rebuild --tls-cert /tmp/certs/cert.pem
Error when launching 'rethinkdb-index-rebuild': No such file or directory
The rethinkdb-index-rebuild command depends on the RethinkDB Python driver, which must be installed.
If the Python driver is already installed, make sure that the PATH environment variable
includes the location of the backup scripts, and that the current user has permission to
access and run the scripts.
Instructions for installing the RethinkDB Python driver are available here:
http://www.rethinkdb.com/docs/install-drivers/python/

Describe the solution you'd like Include the python drivers in the container for running these utilities.

Describe alternatives you've considered I manually installed python in the container and then pip and rethinkdb (somewhat involved). I also installed the python drivers on my host machine for completing this.

mishawakerman avatar Jul 24 '20 02:07 mishawakerman

The steps for installing the drivers in the container...

apt update
apt install software-properties-common
add-apt-repository ppa:deadsnakes/ppa
apt update
apt install python3
apt install python3-pip
pip3 install rethinkdb

mishawakerman avatar Jul 24 '20 02:07 mishawakerman

The best way to solve is create another dockerfile with this contents

FROM rethinkdb:latest

RUN apt-get update; exit 0
RUN apt install -y python3 python3-pip
RUN pip3 install rethinkdb

zafhiel avatar Sep 11 '20 00:09 zafhiel

I would also create a 2nd docker file that contains Python. CIs can pickup the Python-less image to run tests. Users can pickup the Python version and run RDB in production.

ghost avatar Sep 14 '20 07:09 ghost

I used a variation of the suggestion by @zafhiel but instead of an extra Dockerfile I just added the required packages in an earlier stage.

FROM rethinkdb AS base
RUN apt update && apt install -y python3 python3-pip && pip3 install rethinkdb

FROM base AS db
COPY --chmod=0755 ./entrypoint.sh /run/
ENTRYPOINT /run/entrypoint.sh

This way the first stage is cached so if the entrypoint script changes then only the final stage needs to be rebuilt.

besworks avatar Apr 28 '22 14:04 besworks

I confirm that a python version can be very interesting while I'm using RethinkDB inside Kubernetes. CronJob to backup the database needs to build and store a derived image to be able to connect to the service. Having a rethinkdb:2.4.2-python can avoid us to build and store the image ourselves.

metal3d avatar Jul 11 '22 12:07 metal3d

@metal3d, I maintain an Alpine based image with the python drivers included which you could use.

docker pull besworks/rethinkdb:python

besworks avatar Jul 11 '22 13:07 besworks

The best way to solve is create another dockerfile with this contents

FROM rethinkdb:latest

RUN apt-get update; exit 0
RUN apt install -y python3 python3-pip
RUN pip3 install rethinkdb

This answer worked best for me. Other answers required modifications to the docker-deamon or on @besworks own image the browser interface lacked some features.

Also if someone is interesed this is how my Dockerfile looked in the end:

FROM rethinkdb:2.4.2

RUN apt-get update; exit 0
RUN apt install -y python3 python3-pip
RUN pip3 install rethinkdb

RUN mkdir -p /srv/rethinkdb

WORKDIR /srv/rethinkdb
COPY ./backup ./backup
COPY ./scripts ./scripts

In the scripts folder I have two files:

./dump.sh

# !/bin/bash
# dumping the data to a backup file with date prefix
rethinkdb dump -f /srv/rethinkdb/backup/$(date -d "today" +"%Y-%m-%d.%H:%M").tar.gz

./restore.sh

# !/bin/bash
# restoring the db from the latest dumped file
newest=$(ls ../backup | sort -t _ -k 2,2 | tail -n 1)
rethinkdb restore /srv/rethinkdb/backup/$newest

Also my docker-compose part is:

  rethinkdb:
    build: ./rethinkdb
    ports:
      - 29015:29015
      - 28015:28015
      - 8080:8080
    volumes:
      - ./rethinkdb/backup:/srv/rethinkdb/backup
    command: rethinkdb --bind all

u-rogel avatar Apr 21 '23 08:04 u-rogel

@u-rogel didn't specifically mention what features were lacking from the web interface, but I'm pretty sure this issue that affects v2.4.3 is what he was referring to.

besworks avatar Jul 19 '23 05:07 besworks