version: '3.1' services: # Dependencies for running unit tests and for running the 'irma' command line tool using one of the test configurations. postgres: image: postgres:13 environment: POSTGRES_USER: testuser POSTGRES_PASSWORD: testpassword POSTGRES_DB: test networks: # We use a localhost alias such that the test configuration also works for users who run it without Docker. irma-net: aliases: - postgres.localhost ports: - 5432:5432 postgres-init: image: postgres:13 environment: PGHOST: postgres PGUSER: testuser PGPASSWORD: testpassword PGDATABASE: test networks: - irma-net depends_on: - postgres volumes: - ./server/keyshare/schema.sql:/schema.sql - ./server/keyshare/cleanup.sql:/cleanup.sql # We have to wait until the database is up and running. # Database might already be running, so we need to do a cleanup first. command: /bin/sh -c "sleep 5 && psql -f cleanup.sql && psql -f schema.sql" mailhog: image: mailhog/mailhog networks: # We use a localhost alias such that the test configuration also works for users who run it without Docker. irma-net: aliases: - mailhog.localhost ports: - 1025:1025 - 8025:8025 # Port of the web interface # Service to run unit tests test: image: golang:1.16 # Add a test profile to prevent this service to be included when running docker-compose up. profiles: - test volumes: - .:/irmago depends_on: - postgres - mailhog # The tests assume postgres and mailhog can be accessed on localhost. Therefore, we use host networking. network_mode: host working_dir: /irmago entrypoint: go test -p 1 command: ./... # Service to run the 'irma' command line tool irma: build: . image: privacybydesign/irma:edge # Add a run profile to prevent this service to be included when running docker-compose up. profiles: - run volumes: - .:/irmago working_dir: /irmago depends_on: - postgres - postgres-init - mailhog networks: - irma-net # Docker Desktop for MacOS does not support exposing ports when using host networking. Therefore, # we have to use bridge networking and expose the ports manually. # https://github.com/docker/for-mac/issues/1031 networks: irma-net: driver: bridge