Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include python drivers in container #57

Open
mishawakerman opened this issue Jul 24, 2020 · 8 comments
Open

Include python drivers in container #57

mishawakerman opened this issue Jul 24, 2020 · 8 comments

Comments

@mishawakerman
Copy link

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
Copy link
Author

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

@zafhiel
Copy link

zafhiel commented Sep 11, 2020

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

@ghost
Copy link

ghost commented Sep 14, 2020

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.

@besworks
Copy link

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.

@metal3d
Copy link

metal3d commented Jul 11, 2022

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.

@besworks
Copy link

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

docker pull besworks/rethinkdb:python

@u-rogel
Copy link

u-rogel commented Apr 21, 2023

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

@besworks
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants