Runing docker services as multi container in gitlab for integration testing, getting postgresql host not yet available and timeout/inavlid argument for baseurl.
Image is working as expected during docker-compose but then failing to establish the communication between them when used as services in gitlab job.
app:
build:
context: β¦/
dockerfile: ./Dockerfile
expose:
- β80β
container_name: app
ports:
- β8080:80β
# - β7896:7896β
environment:
- WAIT_HOSTS=db:5432
- WAIT_HOSTS_TIMEOUT=120
- CB_database_JDBC_Username=user
- CB_database_JDBC_Password=password
- CB_database_JDBC_Driver=org.postgresql.Driver
- CB_database_JDBC_ConnectionURL=jdbc:postgresql://db:5432/codebeamer
# make this the one you have a license for (the license must be for this mac address preceded by βLIN-β) # 6 & 7 in the end have expired trial license
- DEBUG=TRUE
volumes:
- app-repository-docs:/home/appuser/codebeamer/repository/docs
- app-repository-search:/home/appuser/codebeamer/repository/search
- app-logs:/home/appuser/codebeamer/logs
depends_on:
- db
networks:
- mynet
networks:
mynet:
driver: bridge
FROM intland/codebeamer:2.0.0.1
ADD ./deployment_docker.tar codebeamer/tomcat/webapps/ROOT
And my docker-compose.yaml file:
version: '2.1'
services:
db:
image: intland/postgres:debian-12.6.3
container_name: db
environment:
- POSTGRESQL_USER=user
- POSTGRESQL_PASSWORD=password
- POSTGRESQL_DATABASE=codebeamer
- TZ=UTC
# ports:
# - 5432:5432
volumes:
- db-data:/var/lib/postgresql/data
networks:
- mynet
retina-app:
build:
context: ../
dockerfile: ./Dockerfile
expose:
- "8080"
container_name: retina-app
ports:
- "8080:8080"
# - "7896:7896"
environment:
- WAIT_HOSTS=db:5432
- WAIT_HOSTS_TIMEOUT=120
- CB_database_JDBC_Username=user
- CB_database_JDBC_Password=password
- CB_database_JDBC_Driver=org.postgresql.Driver
- CB_database_JDBC_ConnectionURL=jdbc:postgresql://db:5432/codebeamer
# make this the one you have a license for (the license must be for this mac address preceded by "LIN-") # 6 & 7 in the end have expired trial license :)
- DEBUG=TRUE
volumes:
- app-repository-docs:/home/appuser/codebeamer/repository/docs
- app-repository-search:/home/appuser/codebeamer/repository/search
- app-logs:/home/appuser/codebeamer/logs
depends_on:
- db
networks:
- mynet
networks:
mynet:
driver: bridge
ipam:
driver: default
volumes:
db-data:
app-repository-docs:
repository-search:
app-logs:
Here is my gitlab job which uses the above pushed images from CI registry as services.
*.gitlab-ci.yml
test:int
stage: test
image: docker-cache.repository.intranet.xxx.com/markhobson/maven-chrome:jdk-8
variables:
# # postgres db service vars
POSTGRESQL_USER: user
POSTGRESQL_PASSWORD: password
POSTGRESQL_DATABASE: codebeamer
POSTGRESQL_HOST_AUTH_METHOD: trust
# DOCKER_DRIVER: "overlay"
# DOCKER_TLS_CERTDIR: "/certs"
# # codebeamer service vars
WAIT_HOSTS: "app:8080"
services:
# - docker-cache.repository.intranet.roche.com/docker:dind
# - name: docker-cache.repository.intranet.roche.com/markhobson/maven-chrome:jdk-8
- name: intland/postgres:debian-12.6.3
alias: db
- name: registry.code.xxx.com/xxx/cor/ptcm:dev
alias: app
script:
- mvn verify [args] <filepath>
Error during this job execution:
2023-11-14T17:36:34.537005133Z /usr/bin/fc-cache-64: succeeded
2023-11-14T17:36:34.537012254Z Refreshed available fonts cache
2023-11-14T17:36:34.636478041Z Docker-compose-wait starting with configuration:
2023-11-14T17:36:34.636518290Z ------------------------------------------------
2023-11-14T17:36:34.636527694Z - Hosts to be waiting for: [db:5432]
2023-11-14T17:36:34.636535313Z - Timeout before failure: 30 seconds
2023-11-14T17:36:34.636542638Z - Sleeping time before checking for hosts availability: 0 seconds
2023-11-14T17:36:34.636550254Z - Sleeping time once all hosts are available: 0 seconds
2023-11-14T17:36:34.636557382Z ------------------------------------------------
2023-11-14T17:36:34.636564594Z Checking availability of db:5432
2023-11-14T17:36:34.745280629Z Host db:5432 not yet available
2023-11-14T17:36:35.746491413Z Host db:5432 not yet available
2023-11-14T17:36:36.747713935Z Host db:5432 not yet available
2023-11-14T17:36:37.748797686Z Host db:5432 not yet available
2023-11-14T17:36:38.749887437Z Host db:5432 not yet available
**Note: the same docker compose is working as expected [ getting " db:5432 now available" status] when 'docker-compose up --build' is done**
Can you help me to understand how your problem with your gitlab ci pipeline is a docker problem?
From my perspective, it looks like a problem with the gitlab ci pipeline. If this is the case, then you might want to post this question in a gitlab-ci related forum.