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 Sep 12, 2023
1 parent 006332b commit 2ed1236
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 8 deletions.
6 changes: 5 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,13 @@ CACHE_BUSTING_STATIC_ENABLED=False

MEMCACHED_ENABLED=False
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=200
CLIENT_RESULTS_LIMIT=5
Expand Down
6 changes: 5 additions & 1 deletion .env_dev
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,13 @@ CACHE_BUSTING_STATIC_ENABLED=False

MEMCACHED_ENABLED=False
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=200
CLIENT_RESULTS_LIMIT=5
Expand Down
6 changes: 5 additions & 1 deletion .env_local
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,13 @@ CACHE_BUSTING_STATIC_ENABLED=False

MEMCACHED_ENABLED=False
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=200
CLIENT_RESULTS_LIMIT=5
Expand Down
6 changes: 5 additions & 1 deletion .env_test
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,13 @@ CACHE_BUSTING_STATIC_ENABLED=False

MEMCACHED_ENABLED=False
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=200
CLIENT_RESULTS_LIMIT=5
Expand Down
13 changes: 13 additions & 0 deletions docker-compose-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@ services:
- statics:/mnt/volumes/statics
restart: unless-stopped

# 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/letsencrypt:latest
Expand Down
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,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:1.25.1
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
5 changes: 2 additions & 3 deletions scripts/docker/base/ubuntu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RUN mkdir -p /usr/src/geonode
## Enable postgresql-client-15
RUN apt-get update -y && apt-get install curl wget unzip gnupg2 -y
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
# will install python3.10
# will install python3.10
RUN apt-get install lsb-core -y
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" |tee /etc/apt/sources.list.d/pgdg.list

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

# Activate "memcached"
RUN apt-get install -y memcached
# Install "sherlock" to be used with "memcached"
RUN pip install sherlock

# Cleanup apt update lists
Expand Down

0 comments on commit 2ed1236

Please sign in to comment.