Skip to content

Commit

Permalink
Add own service for memcached
Browse files Browse the repository at this point in the history
Goal: one service per container

- add own service for memcached

- remove memcached from geonode image

- add MEMCACHED_OPTIONS variable to env files

- enable memcached by default
  • Loading branch information
EHJ-52n committed Feb 17, 2022
1 parent 6363bac commit c610080
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 13 deletions.
12 changes: 8 additions & 4 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,15 @@ GEOIP_PATH=/mnt/volumes/statics/geoip.db

CACHE_BUSTING_STATIC_ENABLED=False

MEMCACHED_ENABLED=False
MEMCACHED_ENABLED=True
MEMCACHED_BACKEND=django.core.cache.backends.memcached.MemcachedCache
MEMCACHED_LOCATION=127.0.0.1:11211
MEMCACHED_LOCATION=memcached:11211
MEMCACHED_LOCK_EXPIRE=3600
MEMCACHED_LOCK_TIMEOUT=10
#
# Options for memcached binary, e.g. -vvv to log all requests and cache hits
#
MEMCACHED_OPTIONS=

MAX_DOCUMENT_SIZE=2
CLIENT_RESULTS_LIMIT=5
Expand Down Expand Up @@ -213,9 +217,9 @@ LDAP_GROUP_PROFILE_MEMBER_ATTR=uniqueMember

# expressed in KB
# CELERY__MAX_MEMORY_PER_CHILD="200000"
# ##
# ##
# Note right autoscale value must coincide with worker concurrency value
# CELERY__AUTOSCALE_VALUES="1,4"
# CELERY__AUTOSCALE_VALUES="1,4"
# CELERY__WORKER_CONCURRENCY="4"
# ##
# CELERY__OPTS="--without-gossip --without-mingle -Ofair -B -E"
Expand Down
8 changes: 6 additions & 2 deletions .env_dev
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,15 @@ SECRET_KEY='myv-y4#7j-d*p-__@j#*3z@!y24fz8%^z2v6atuy4bo9vqr1_a'

CACHE_BUSTING_STATIC_ENABLED=False

MEMCACHED_ENABLED=False
MEMCACHED_ENABLED=True
MEMCACHED_BACKEND=django.core.cache.backends.memcached.MemcachedCache
MEMCACHED_LOCATION=127.0.0.1:11211
MEMCACHED_LOCATION=memcached:11211
MEMCACHED_LOCK_EXPIRE=3600
MEMCACHED_LOCK_TIMEOUT=10
#
# Options for memcached binary, e.g. -vvv to log all requests and cache hits
#
MEMCACHED_OPTIONS=

MAX_DOCUMENT_SIZE=2
CLIENT_RESULTS_LIMIT=5
Expand Down
8 changes: 6 additions & 2 deletions .env_local
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,15 @@ SECRET_KEY='myv-y4#7j-d*p-__@j#*3z@!y24fz8%^z2v6atuy4bo9vqr1_a'

CACHE_BUSTING_STATIC_ENABLED=False

MEMCACHED_ENABLED=False
MEMCACHED_ENABLED=True
MEMCACHED_BACKEND=django.core.cache.backends.memcached.MemcachedCache
MEMCACHED_LOCATION=127.0.0.1:11211
MEMCACHED_LOCATION=memcached:11211
MEMCACHED_LOCK_EXPIRE=3600
MEMCACHED_LOCK_TIMEOUT=10
#
# Options for memcached binary, e.g. -vvv to log all requests and cache hits
#
MEMCACHED_OPTIONS=

MAX_DOCUMENT_SIZE=2
CLIENT_RESULTS_LIMIT=5
Expand Down
8 changes: 6 additions & 2 deletions .env_test
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,15 @@ GEOIP_PATH=/mnt/volumes/statics/geoip.db

CACHE_BUSTING_STATIC_ENABLED=False

MEMCACHED_ENABLED=False
MEMCACHED_ENABLED=True
MEMCACHED_BACKEND=django.core.cache.backends.memcached.MemcachedCache
MEMCACHED_LOCATION=127.0.0.1:11211
MEMCACHED_LOCATION=memcached:11211
MEMCACHED_LOCK_EXPIRE=3600
MEMCACHED_LOCK_TIMEOUT=10
#
# Options for memcached binary, e.g. -vvv to log all requests and cache hits
#
MEMCACHED_OPTIONS=

MAX_DOCUMENT_SIZE=2
CLIENT_RESULTS_LIMIT=5
Expand Down
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ RUN pip install pip --upgrade \
&& pip install pygdal==$(gdal-config --version).* \
flower==0.9.4

# Activate "memcached"
RUN apt install -y memcached
RUN pip install pylibmc \
&& pip install sherlock

Expand Down
13 changes: 13 additions & 0 deletions docker-compose-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ services:
- statics:/mnt/volumes/statics
restart: on-failure

# memcached service
memcached:
image: memcached:alpine
container_name: memcached4${COMPOSE_PROJECT_NAME}
command: memcached ${MEMCACHED_OPTIONS}
restart: on-failure
healthcheck:
test: nc -z 127.0.0.1 11211
interval: 30s
timeout: 30s
retries: 5
start_period: 30s

# Gets and installs letsencrypt certificates
letsencrypt:
image: geonode/spcgeonode:letsencrypt-3.1
Expand Down
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@ services:
entrypoint: ["/usr/src/geonode/entrypoint.sh"]
command: "celery-cmd"

# memcached service
memcached:
image: memcached:alpine
container_name: memcached4${COMPOSE_PROJECT_NAME}
command: memcached ${MEMCACHED_OPTIONS}
restart: on-failure
healthcheck:
test: nc -z 127.0.0.1 11211
interval: 30s
timeout: 30s
retries: 5
start_period: 30s

# Nginx is serving django static and media files and proxies to django and geonode
geonode:
image: geonode/nginx:3.x
Expand Down
1 change: 0 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ invoke () {

# Start cron && memcached services
service cron restart
service memcached restart

echo $"\n\n\n"
echo "-----------------------------------------------------"
Expand Down

0 comments on commit c610080

Please sign in to comment.