I'm trying to install dspace7.6 in docker swarm using traefik to manage my containers, but my problem is that when I access the url of my UI, I don't see the data appear (Communities, Collections, Items). I've inserted this data directly into my database.
This is my docker compose file to launch my back-end services managed by traefik. It works fine except that I can't display the data in my postgresql database. I doubt that the url of my environment variable for establishing a connection (db__P__url:) is not properly configured. Could you give me an idea of how to configure it properly to access the data. my_db_ip_adress is the ip address that the traefik-net network assigns to my dspacedb service. Thanks for help.
docker-compose-rest.yml
version: '3.9'
volumes:
assetstore:
networks:
traefik-net:
external: true
dspace:
driver: overlay
external: true
services:
# DSpace (backend) webapp container
dspace:
environment:
dspace__P__dir: /dspace
dspace__P__server__P__url: http://dspace-api.localhost/server
dspace__P__ui__P__url: http://dspace.localhost
dspace__P__name: 'DSpace Started with Docker Compose'
# db.url: Ensure we are using the 'dspacedb' image for our database
db__P__url: 'jdbc:postgresql://my_db_ip_adress:5432/dspace'
# solr.server: Ensure we are using the 'dspacesolr' image for Solr
solr__P__server: http://solr.localhost/solr
image: "${DOCKER_OWNER:-dspace}/dspace:${DSPACE_VER:-latest-test}"
depends_on:
- dspacedb
networks:
- traefik-net
- dspace
deploy:
labels:
- "traefik.enable=true"
- "traefik.http.routers.dspace.entrypoints=http"
- "traefik.http.routers.dspace.rule=Host(`dspace-api.localhost`)"
- "traefik.http.routers.dspace.service=dspace"
- "traefik.http.services.dspace.loadbalancer.server.port=8080"
volumes:
- assetstore:/dspace/assetstore
- solr_configs:/dspace/solr
entrypoint:
- /bin/bash
- '-c'
- |
while (!</dev/tcp/dspacedb/5432) > /dev/null 2>&1; do sleep 1; done;
/dspace/bin/dspace database migrate
catalina.sh run
dspacedb:
environment:
- PGDATA=/pgdata
- POSTGRES_PASSWORD=dspace
image: dspace/dspace-postgres-pgcrypto
networks:
- traefik-net
- dspace
deploy:
labels:
- "traefik.enable=true"
- "traefik.tcp.routers.dspacedb.entrypoints=postgres"
- "traefik.tcp.routers.dspacedb.rule=HostSNI(`*`)"
- "traefik.tcp.routers.dspacedb.tls=false"
- "traefik.tcp.routers.dspacedb.service=dspacedb"
- "traefik.tcp.services.dspacedb.loadbalancer.server.port=5432"
volumes:
- /data/services/postgres/pgdata:/pgdata
dspacesolr:
image: solr:8.11-slim
depends_on:
- dspace
networks:
- traefik-net
- dspace
deploy:
labels:
- "traefik.enable=true"
- "traefik.http.routers.dspacesolr.entrypoints=http"
- "traefik.http.routers.dspacesolr.rule=Host(`solr.localhost`)"
- "traefik.http.routers.dspacesolr.service=dspacesolr"
- "traefik.http.services.dspacesolr.loadbalancer.server.port=8983"
working_dir: /var/solr/data
volumes:
- solr_data:/var/solr/data
entrypoint:
- /bin/bash
- '-c'
- |
init-var-solr
precreate-core authority /opt/solr/server/solr/configsets/authority
cp -r /opt/solr/server/solr/configsets/authority/* authority
precreate-core oai /opt/solr/server/solr/configsets/oai
cp -r /opt/solr/server/solr/configsets/oai/* oai
precreate-core search /opt/solr/server/solr/configsets/search
cp -r /opt/solr/server/solr/configsets/search/* search
precreate-core statistics /opt/solr/server/solr/configsets/statistics
cp -r /opt/solr/server/solr/configsets/statistics/* statistics
exec solr -f
volumes:
assetstore:
pgdata:
solr_data:
solr_configs:
I don't know how you have done the localhost thing - perhaps a local install of dnsmasq or ../hosts entries? But you can also take advantage of services like localtest.me or local.gd to achieve the same result. e.g.
foo.local.gdalways resolves to 127.0.0.1Traefik's HostSNI routing only works for TLS encrypted connections. I'm guessing that the traefik config on dspacedb is so much noise.
This is a single node swarm? I also don't see any real attempt to persist dspacedb's data in a cluster aware way?
To the crux of the issue: each time a service task restarts it will get new IPs. I am guessing the IP you have embedded in the config is old. Why not just make use of dockers mesh network: Docker attaches a dns server to each container that knows what networks it is attached to which will resolve any services by name. As you have attached dspace and dspacedb to the same network, this config will suffice: