Skip to content

Commit e82b3e6

Browse files
committed
add scaling to Docker Compose setup
1 parent 0e77846 commit e82b3e6

File tree

3 files changed

+121
-11
lines changed

3 files changed

+121
-11
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# =================================================================
2+
#
3+
# Authors: Ricardo Garcia Silva <ricardo.garcia.silva@gmail.com>
4+
# Authors: Tom Kralidis <tomkralidis@gmail.com>
5+
#
6+
# Copyright (c) 2017 Ricardo Garcia Silva
7+
# Copyright (c) 2025 Tom Kralidis
8+
#
9+
# Permission is hereby granted, free of charge, to any person
10+
# obtaining a copy of this software and associated documentation
11+
# files (the "Software"), to deal in the Software without
12+
# restriction, including without limitation the rights to use,
13+
# copy, modify, merge, publish, distribute, sublicense, and/or sell
14+
# copies of the Software, and to permit persons to whom the
15+
# Software is furnished to do so, subject to the following
16+
# conditions:
17+
#
18+
# The above copyright notice and this permission notice shall be
19+
# included in all copies or substantial portions of the Software.
20+
#
21+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23+
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25+
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28+
# OTHER DEALINGS IN THE SOFTWARE.
29+
#
30+
# =================================================================
31+
#
32+
#
33+
# This docker compose file demos how to use the pycsw docker image with a
34+
# PostgreSQL/PostGIS database.
35+
#
36+
# docker compose usage:
37+
#
38+
# docker compose up
39+
#
40+
# docker stack (in a docker swarm):
41+
#
42+
# PYCSW_DOCKER_IMAGE=2.1-dev docker stack deploy --compose-file docker-compose.yml pycsw
43+
#
44+
45+
services:
46+
db:
47+
container_name: db
48+
image: postgis/postgis:12-3.0-alpine
49+
environment:
50+
POSTGRES_USER: postgres
51+
POSTGRES_PASSWORD: mypass
52+
POSTGRES_DB: pycsw
53+
PGDATA: /var/lib/postgresql/data/pgdata
54+
volumes:
55+
- db-data:/var/lib/postgresql/data/pgdata
56+
ports:
57+
- 5432:5432
58+
networks:
59+
- pycsw-net
60+
pycsw:
61+
image: geopython/pycsw:${PYCSW_DOCKER_IMAGE}
62+
environment:
63+
PYCSW_SERVER_URL: http://localhost:8000
64+
# deploy 5 instances of pycsw, from ports 8000-8004
65+
deploy:
66+
replicas: 5
67+
ports:
68+
- 8000-8004:8000
69+
volumes:
70+
- ./pycsw.yml:/etc/pycsw/pycsw.yml
71+
networks:
72+
- pycsw-net
73+
networks:
74+
pycsw-net:
75+
76+
volumes:
77+
db-data:

docker/compose/docker-compose.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Authors: Tom Kralidis <tomkralidis@gmail.com>
55
#
66
# Copyright (c) 2017 Ricardo Garcia Silva
7-
# Copyright (c) 2020 Tom Kralidis
7+
# Copyright (c) 2025 Tom Kralidis
88
#
99
# Permission is hereby granted, free of charge, to any person
1010
# obtaining a copy of this software and associated documentation
@@ -33,19 +33,16 @@
3333
# This docker compose file demos how to use the pycsw docker image with a
3434
# PostgreSQL/PostGIS database.
3535
#
36-
# docker-compose usage:
36+
# docker compose usage:
3737
#
38-
# docker-compose up
38+
# docker compose up
3939
#
4040
# docker stack (in a docker swarm):
4141
#
4242
# PYCSW_DOCKER_IMAGE=2.1-dev docker stack deploy --compose-file docker-compose.yml pycsw
4343
#
4444

45-
version: "3.8"
46-
4745
services:
48-
4946
db:
5047
container_name: db
5148
image: postgis/postgis:12-3.0-alpine
@@ -58,7 +55,8 @@ services:
5855
- db-data:/var/lib/postgresql/data/pgdata
5956
ports:
6057
- 5432:5432
61-
58+
networks:
59+
- pycsw-net
6260
pycsw:
6361
container_name: pycsw
6462
image: geopython/pycsw:${PYCSW_DOCKER_IMAGE}
@@ -68,7 +66,11 @@ services:
6866
- 8000:8000
6967
volumes:
7068
- ./pycsw.yml:/etc/pycsw/pycsw.yml
69+
networks:
70+
- pycsw-net
7171

72+
networks:
73+
pycsw-net:
7274

7375
volumes:
7476
db-data:

docs/docker.rst

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ PostgreSQL repositories
114114
Specifying a PostgreSQL repository is just a matter of configuring a custom
115115
pycsw.yml file with the correct specification.
116116

117-
Check `pycsw's github repository`_ for an example of a docker-compose/stack
117+
Check `pycsw's GitHub repository`_ for an example of a docker compose/stack
118118
file that spins up a postgis database together with a pycsw instance.
119119

120120

@@ -175,6 +175,36 @@ example by running::
175175

176176
firefox docs/_build/html/index.html
177177

178+
Docker Compose
179+
==============
180+
181+
For `Docker Compose`_ deployment, run the following in ``docker/compose``:
182+
183+
.. code-block:: bash
184+
185+
PYCSW_DOCKER_IMAGE=latest docker compose up
186+
187+
188+
.. note::
189+
190+
The ``PYCSW_DOCKER_IMAGE`` setting is required to set the Docker image version/tag.
191+
192+
193+
Scaling
194+
-------
195+
196+
To scale via Docker Compose, run the following in ``docker/compose``:
197+
198+
.. code-block:: bash
199+
200+
PYCSW_DOCKER_IMAGE=latest docker compose -f docker-compose.scale.yml up
201+
202+
.. note::
203+
204+
In ``docker/compose/docker-compose.scale.yml``, adjust the ``services.pycsw.deploy``
205+
and services.pycsw.ports values to scale accordingly. The port range specified must
206+
match the number of replicas defined.
207+
178208
Kubernetes
179209
==========
180210

@@ -200,6 +230,7 @@ For Kubernetes deployment via `Helm`_, run the following in ``docker/helm``:
200230
.. _`Docker`: https://www.docker.com
201231
.. _`geopython Docker Hub`: https://hub.docker.com/r/geopython/pycsw
202232
.. _`GitHub Container Registry`: https://github.com/geopython/pycsw/pkgs/container/pycsw
203-
.. _pycsw's github repository: https://github.com/geopython/pycsw/tree/master/docker
204-
.. _Kubernetes: https://kubernetes.io/
205-
.. _Helm: https://helm.sh
233+
.. _pycsw's GitHub repository: https://github.com/geopython/pycsw/tree/master/docker
234+
.. _`Docker Compose`: https://docs.docker.com/compose
235+
.. _`Kubernetes`: https://kubernetes.io/
236+
.. _`Helm`: https://helm.sh

0 commit comments

Comments
 (0)