Hello, I’m new to CircleCI (and this community), thanks for having me!
I have a docker-compose.yml that, among other things, spins up a postgres database and then runs an initialization script, which is mounted in /docker-entrypoint-initdb.d. In that directory is a shell script that creates some roles and extensions, and then invokes the SQL files mounted as below. This works beautifully on my local Linux laptop (and on a coworkers mac for example), but in CircleCI it fails because the script is ignored:
…
“kalidasa-db-1 | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*”
…
I’ve spent quite a while looking for reasons that Docker would ignore scripts in that directory, and have explored things like:
- Explicitly setting execute permission
- Using an “ENTRYPOINT” directive in the config to run the script explicitly
- Using a machine executor instead of docker
- Mounting the script itself instead of the directory it lives in
- Different versions of docker compose etc.
I’ve been through the docs and have searched discussions..could be I’ve missed something but I’m not sure if the discrepancy is more Docker or CircleCI related. Again, it has consistently worked locally. Here is the snippet from the docker-compose.yml
kalidasa-db:
image: postgis/postgis:13-3.5
ports:
- "5434:5432"
volumes:
- ./kalidasa-db:/docker-entrypoint-initdb.d
- ./db/kalidasa-roles.sql:/tmp/01-roles.sql
- ./data/kalidasa-full.sql:/tmp/kalidasa-full.sql
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=postgres
- POSTGRES_INITDB_ARGS=--encoding=UTF8 --auth-local=trust --auth-host=trust
- INIT_CHECK_TABLE=clients
healthcheck:
test: ["CMD-SHELL", "pg_isready -h localhost -p 5432 -U understory -d kalidasa && psql -U understory -d kalidasa -c \"SELECT 1 FROM information_schema.tables WHERE table_name = 'clients'\" | grep -q 1"]
interval: 5s
timeout: 5s
retries: 10
…and the relevant snippet from the CircleCI config:
jobs:
docker-purge:
docker:
- image: cimg/base:2020.01
parallelism: 30
steps:
- setup_remote_docker
- run: docker volume prune -f
integration_test:
docker:
- image: cimg/openjdk:8.0
steps:
- checkout
- restore_cache:
keys:
- v2-dependencies-{{ checksum "pom.xml" }}
- setup_remote_docker:
docker_layer_caching: true
- run:
name: Install Docker Compose
command: |
sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
- run:
name: Install Docker Compose plugin
command: |
DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
mkdir -p $DOCKER_CONFIG/cli-plugins
curl -SL "https://github.com/docker/compose/releases/download/v2.23.3/docker-compose-$(uname -s)-$(uname -m)" -o $DOCKER_CONFIG/cli-plugins/docker-compose
chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose
docker compose version
- run:
name: Run integration tests
command: docker compose up
- run:
name: Cleanup
command: docker compose down -v
when: always
Any insight or tips would be very appreciated!