Skip to content

Commit

Permalink
Merge pull request #1100 from BlackOrder/docker-restapi-jemalloc
Browse files Browse the repository at this point in the history
Docker restapi + slim + jemalloc
  • Loading branch information
farirat authored Jan 11, 2023
2 parents 8c26145 + 9321573 commit 798ac30
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
36 changes: 25 additions & 11 deletions docker/Dockerfile.restapi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3-buster
FROM python:3.11-slim-bullseye

MAINTAINER Jookies LTD <[email protected]>

Expand All @@ -9,22 +9,24 @@ RUN groupadd -r jasmin && useradd -r -g jasmin jasmin
RUN apt-get update && apt-get install -y \
libffi-dev \
libssl-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Run python with jemalloc
# More on this:
# - https://zapier.com/engineering/celery-python-jemalloc/
# - https://paste.pics/581cc286226407ab0be400b94951a7d9
libjemalloc2

# For RestAPI MODE
ENV RESTAPI_MODE 0
ENV RESTAPI_OLD_HTTP_HOST '127.0.0.1'
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

ENV ENABLE_PUBLISH_SUBMIT_SM_RESP 0
# Run python with jemalloc
ENV LD_PRELOAD /usr/lib/x86_64-linux-gnu/libjemalloc.so.2

ENV ROOT_PATH /
ENV CONFIG_PATH /etc/jasmin
ENV RESOURCE_PATH /etc/jasmin/resource
ENV STORE_PATH /etc/jasmin/store
ENV RESOURCE_PATH ${CONFIG_PATH}/resource
ENV STORE_PATH ${CONFIG_PATH}/store
ENV LOG_PATH /var/log/jasmin

RUN mkdir -p ${CONFIG_PATH} ${RESOURCE_PATH} ${STORE_PATH} ${LOG_PATH}
RUN mkdir -p ${RESOURCE_PATH} ${STORE_PATH} ${LOG_PATH}
RUN chown jasmin:jasmin ${CONFIG_PATH} ${RESOURCE_PATH} ${STORE_PATH} ${LOG_PATH}

WORKDIR /build
Expand All @@ -39,10 +41,22 @@ RUN pip install gunicorn
ENV UNICODEMAP_JP unicode-ascii

COPY misc/config/*.cfg ${CONFIG_PATH}/
COPY misc/config/resource/*.xml ${RESOURCE_PATH}/
COPY misc/config/resource ${RESOURCE_PATH}

WORKDIR /etc/jasmin

# Default Redis and RabbitMQ connections
ENV AMQP_BROKER_HOST 'rabbitmq'
ENV AMQP_BROKER_PORT 5672
ENV REDIS_CLIENT_HOST 'redis'
ENV REDIS_CLIENT_PORT 6379

# For RestAPI MODE
ENV RESTAPI_MODE 0
ENV RESTAPI_OLD_HTTP_HOST '127.0.0.1'

ENV ENABLE_PUBLISH_SUBMIT_SM_RESP 0

# Change binding host for jcli
RUN sed -i '/\[jcli\]/a bind=0.0.0.0' ${CONFIG_PATH}/jasmin.cfg
# Change binding port for redis, and amqp
Expand Down
12 changes: 6 additions & 6 deletions docker/restapi-docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
set -e

# Change binding host:port for redis, and amqp
sed -i "/\[redis-client\]/,/host=/ s/host=.*/host=$REDIS_CLIENT_HOST/" /etc/jasmin/jasmin.cfg
sed -i "/\[redis-client\]/,/port=/ s/port=.*/port=$REDIS_CLIENT_PORT/" /etc/jasmin/jasmin.cfg
sed -i "/\[amqp-broker\]/,/host=/ s/host=.*/host=$AMQP_BROKER_HOST/" /etc/jasmin/jasmin.cfg
sed -i "/\[amqp-broker\]/,/port=/ s/port=.*/port=$AMQP_BROKER_PORT/" /etc/jasmin/jasmin.cfg
sed -i "/\[redis-client\]/,/host=/ s/host=.*/host=$REDIS_CLIENT_HOST/" ${CONFIG_PATH}/jasmin.cfg
sed -i "/\[redis-client\]/,/port=/ s/port=.*/port=$REDIS_CLIENT_PORT/" ${CONFIG_PATH}/jasmin.cfg
sed -i "/\[amqp-broker\]/,/host=/ s/host=.*/host=$AMQP_BROKER_HOST/" ${CONFIG_PATH}/jasmin.cfg
sed -i "/\[amqp-broker\]/,/port=/ s/port=.*/port=$AMQP_BROKER_PORT/" ${CONFIG_PATH}/jasmin.cfg

echo 'Cleaning lock files'
rm -f /tmp/*.lock
Expand All @@ -23,11 +23,11 @@ else
if [ "$ENABLE_PUBLISH_SUBMIT_SM_RESP" = 1 ]; then
# Enable publish_submit_sm_resp
echo 'Enabling publish_submit_sm_resp'
sed -i "s/.*publish_submit_sm_resp\s*=.*/publish_submit_sm_resp=True/g" /etc/jasmin/jasmin.cfg
sed -i "s/.*publish_submit_sm_resp\s*=.*/publish_submit_sm_resp=True/g" ${CONFIG_PATH}/jasmin.cfg
else
# Disable publish_submit_sm_resp
echo 'Disabling publish_submit_sm_resp'
sed -i "s/.*publish_submit_sm_resp\s*=.*/publish_submit_sm_resp=False/g" /etc/jasmin/jasmin.cfg
sed -i "s/.*publish_submit_sm_resp\s*=.*/publish_submit_sm_resp=False/g" ${CONFIG_PATH}/jasmin.cfg
fi

if [ "$2" = "--enable-interceptor-client" ]; then
Expand Down

0 comments on commit 798ac30

Please sign in to comment.