Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

Add Redis SSL support #6

Merged
merged 9 commits into from
Mar 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:jessie
FROM debian:buster-slim

#
# httpredir.debian.org is often unreliable
Expand All @@ -11,32 +11,36 @@ FROM debian:jessie
# deb http://security.debian.org jessie/updates main\n' \
# > /etc/apt/sources.list

RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
RUN echo "deb http://repo.mongodb.org/apt/debian jessie/mongodb-org/3.4 main" > /etc/apt/sources.list.d/mongodb-org-3.4.list
RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl \
gcc \
python-dev \
python-pip \
python-setuptools \
python3-pip \
python3-dev \
python3-setuptools \
make \
git \
vim \
bzip2 \
mongodb-org \
nginx redis-server \
g++ \
apt-utils \
&& \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/*

RUN curl -sL https://deb.nodesource.com/setup_7.x | bash -
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get install -y --no-install-recommends nodejs

RUN curl -sL https://www.mongodb.org/static/pgp/server-4.4.asc | apt-key add -
RUN echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.4 main" > /etc/apt/sources.list.d/mongodb-org-4.4.list
RUN apt-get update && apt-get install -y mongodb-org

# Download pypy
RUN curl -sL 'https://bitbucket.org/squeaky/portable-pypy/downloads/pypy-5.8-1-linux_x86_64-portable.tar.bz2' > /pypy.tar.bz2 && tar jxvf /pypy.tar.bz2 && rm -rf /pypy.tar.bz2 && mv /pypy-* /pypy
RUN curl -sL 'https://github.com/squeaky-pl/portable-pypy/releases/download/pypy-7.2.0/pypy-7.2.0-linux_x86_64-portable.tar.bz2' > /pypy.tar.bz2 && tar jxvf /pypy.tar.bz2 && rm -rf /pypy.tar.bz2 && mv /pypy* /pypy

# Upgrade pip
RUN pip install --upgrade --ignore-installed pip
Expand All @@ -48,16 +52,16 @@ ADD requirements-base.txt /app/requirements-base.txt
ADD requirements-dev.txt /app/requirements-dev.txt
ADD requirements-dashboard.txt /app/requirements-dashboard.txt

RUN pip3 install -r /app/requirements-heroku.txt && \
pip3 install -r /app/requirements-base.txt && \
pip3 install -r /app/requirements-dev.txt && \
pip3 install -r /app/requirements-dashboard.txt && \
RUN python3 -m pip install -r /app/requirements-heroku.txt && \
python3 -m pip install -r /app/requirements-base.txt && \
python3 -m pip install -r /app/requirements-dev.txt && \
python3 -m pip install -r /app/requirements-dashboard.txt && \
rm -rf ~/.cache

RUN pip install -r /app/requirements-heroku.txt && \
pip install -r /app/requirements-base.txt && \
pip install -r /app/requirements-dev.txt && \
pip install -r /app/requirements-dashboard.txt && \
RUN python -m pip install -r /app/requirements-heroku.txt && \
python -m pip install -r /app/requirements-base.txt && \
python -m pip install -r /app/requirements-dev.txt && \
python -m pip install -r /app/requirements-dashboard.txt && \
rm -rf ~/.cache

RUN /pypy/bin/pip install -r /app/requirements-heroku.txt && \
Expand Down
9 changes: 7 additions & 2 deletions mrq/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,13 @@ def versiontuple(v):
if isinstance(config_obj, basestring):

import redis as pyredis
import redis.connection as pyredisconnection

connection_class = pyredisconnection.Connection
urllib.parse.uses_netloc.append('redis')
redis_url = urllib.parse.urlparse(config_obj)
if redis_url.scheme == "rediss":
connection_class = pyredisconnection.SSLConnection

log.info("%s: Connecting to Redis at %s..." %
(attr, redis_url.hostname))
Expand All @@ -150,10 +154,11 @@ def versiontuple(v):
host=redis_url.hostname,
port=redis_url.port,
db=int((redis_url.path or "").replace("/", "") or "0"),
password=redis_url.password,
password=redis_url.password if redis_url.password is not None else redis_url.username,
max_connections=int(config.get("redis_max_connections")),
timeout=int(config.get("redis_timeout")),
decode_responses=False
decode_responses=False,
connection_class=connection_class
)
return pyredis.StrictRedis(connection_pool=redis_pool)

Expand Down
2 changes: 1 addition & 1 deletion mrq/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = "0.9.21"
VERSION = "0.9.23"

if __name__ == "__main__":
import sys
Expand Down
4 changes: 2 additions & 2 deletions requirements-base.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
argparse>=1.1
redis==2.10.6
pymongo>=3.0.1
pymongo==3.7.2
gevent>=1.2.2
ujson>=1.33
hiredis>=0.1.5
psutil>=5.1.2,<6.0
psutil>=5.1.2,<=5.6.3 # https://github.com/giampaolo/psutil/issues/1659#issuecomment-586032229
objgraph>=1.8.1
termcolor>=1.1.0
subprocess32>=3.2.7; python_version < '3.2' and sys.platform != "win32"
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pylint==1.7.1
pytest-cov==2.4.0
pytest-instafail==0.3.0
pytest-html==1.14.2
pytest-httpbin==0.2.0
pytest-httpbin==1.0.0
pytest-timeout==1.2.0

subprocess32>=3.2.7; python_version < '3.2'
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,6 @@ def get_version():
"Operating System :: OS Independent",
"Topic :: Utilities"
],
long_description=open("README.md").read()
long_description=open("README.md").read(),
long_description_content_type='text/markdown',
)