Skip to content

Commit 9626fbd

Browse files
authored
Add own service for memcached (GeoNode#8818)
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
1 parent 006332b commit 9626fbd

File tree

8 files changed

+48
-8
lines changed

8 files changed

+48
-8
lines changed

.env.sample

+5-1
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,13 @@ CACHE_BUSTING_STATIC_ENABLED=False
177177

178178
MEMCACHED_ENABLED=False
179179
MEMCACHED_BACKEND=django.core.cache.backends.memcached.MemcachedCache
180-
MEMCACHED_LOCATION=127.0.0.1:11211
180+
MEMCACHED_LOCATION=memcached:11211
181181
MEMCACHED_LOCK_EXPIRE=3600
182182
MEMCACHED_LOCK_TIMEOUT=10
183+
#
184+
# Options for memcached binary, e.g. -vvv to log all requests and cache hits
185+
#
186+
MEMCACHED_OPTIONS=
183187

184188
MAX_DOCUMENT_SIZE=200
185189
CLIENT_RESULTS_LIMIT=5

.env_dev

+5-1
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,13 @@ CACHE_BUSTING_STATIC_ENABLED=False
177177

178178
MEMCACHED_ENABLED=False
179179
MEMCACHED_BACKEND=django.core.cache.backends.memcached.MemcachedCache
180-
MEMCACHED_LOCATION=127.0.0.1:11211
180+
MEMCACHED_LOCATION=memcached:11211
181181
MEMCACHED_LOCK_EXPIRE=3600
182182
MEMCACHED_LOCK_TIMEOUT=10
183+
#
184+
# Options for memcached binary, e.g. -vvv to log all requests and cache hits
185+
#
186+
MEMCACHED_OPTIONS=
183187

184188
MAX_DOCUMENT_SIZE=200
185189
CLIENT_RESULTS_LIMIT=5

.env_local

+5-1
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,13 @@ CACHE_BUSTING_STATIC_ENABLED=False
177177

178178
MEMCACHED_ENABLED=False
179179
MEMCACHED_BACKEND=django.core.cache.backends.memcached.MemcachedCache
180-
MEMCACHED_LOCATION=127.0.0.1:11211
180+
MEMCACHED_LOCATION=memcached:11211
181181
MEMCACHED_LOCK_EXPIRE=3600
182182
MEMCACHED_LOCK_TIMEOUT=10
183+
#
184+
# Options for memcached binary, e.g. -vvv to log all requests and cache hits
185+
#
186+
MEMCACHED_OPTIONS=
183187

184188
MAX_DOCUMENT_SIZE=200
185189
CLIENT_RESULTS_LIMIT=5

.env_test

+5-1
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,13 @@ CACHE_BUSTING_STATIC_ENABLED=False
186186

187187
MEMCACHED_ENABLED=False
188188
MEMCACHED_BACKEND=django.core.cache.backends.memcached.MemcachedCache
189-
MEMCACHED_LOCATION=127.0.0.1:11211
189+
MEMCACHED_LOCATION=memcached:11211
190190
MEMCACHED_LOCK_EXPIRE=3600
191191
MEMCACHED_LOCK_TIMEOUT=10
192+
#
193+
# Options for memcached binary, e.g. -vvv to log all requests and cache hits
194+
#
195+
MEMCACHED_OPTIONS=
192196

193197
MAX_DOCUMENT_SIZE=200
194198
CLIENT_RESULTS_LIMIT=5

docker-compose-test.yml

+13
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,19 @@ services:
6868
- statics:/mnt/volumes/statics
6969
restart: unless-stopped
7070

71+
# memcached service
72+
memcached:
73+
image: memcached:alpine
74+
container_name: memcached4${COMPOSE_PROJECT_NAME}
75+
command: memcached ${MEMCACHED_OPTIONS}
76+
restart: on-failure
77+
healthcheck:
78+
test: nc -z 127.0.0.1 11211
79+
interval: 30s
80+
timeout: 30s
81+
retries: 5
82+
start_period: 30s
83+
7184
# Gets and installs letsencrypt certificates
7285
letsencrypt:
7386
image: geonode/letsencrypt:latest

docker-compose.yml

+13
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,19 @@ services:
4646
entrypoint: ["/usr/src/geonode/entrypoint.sh"]
4747
command: "celery-cmd"
4848

49+
# memcached service
50+
memcached:
51+
image: memcached:alpine
52+
container_name: memcached4${COMPOSE_PROJECT_NAME}
53+
command: memcached ${MEMCACHED_OPTIONS}
54+
restart: on-failure
55+
healthcheck:
56+
test: nc -z 127.0.0.1 11211
57+
interval: 30s
58+
timeout: 30s
59+
retries: 5
60+
start_period: 30s
61+
4962
# Nginx is serving django static and media files and proxies to django and geonode
5063
geonode:
5164
image: geonode/nginx:1.25.1

entrypoint.sh

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ invoke () {
1616

1717
# Start cron && memcached services
1818
service cron restart
19-
service memcached restart
2019

2120
echo $"\n\n\n"
2221
echo "-----------------------------------------------------"

scripts/docker/base/ubuntu/Dockerfile

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ RUN mkdir -p /usr/src/geonode
55
## Enable postgresql-client-15
66
RUN apt-get update -y && apt-get install curl wget unzip gnupg2 -y
77
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
8-
# will install python3.10
8+
# will install python3.10
99
RUN apt-get install lsb-core -y
1010
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" |tee /etc/apt/sources.list.d/pgdg.list
1111

@@ -32,8 +32,7 @@ RUN pip3 install uwsgi \
3232
&& pip install pip --upgrade \
3333
&& pip install pygdal==$(gdal-config --version).* flower==0.9.4
3434

35-
# Activate "memcached"
36-
RUN apt-get install -y memcached
35+
# Install "sherlock" to be used with "memcached"
3736
RUN pip install sherlock
3837

3938
# Cleanup apt update lists

0 commit comments

Comments
 (0)