services:
  openssh:
    image: linuxserver/openssh-server@sha256:204b64775f7dfb17761ed0644df348ba3cd811628334cc723aa69d61f4db893d
    environment:
      PUID: '1000'
      PGID: '1000'
      USER_NAME: tester
      USER_PASSWORD: testpass
      PASSWORD_ACCESS: 'true'
      SUDO_ACCESS: 'false'
      PUBLIC_KEY: 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAnF7atOlMGjLStyDOX18TjMUk5v41Xsl+GrO+Kj2o+9 edgeport-test'
    volumes:
      # provisions password-required sudo for tester (see the script) so sudo tests are real
      - ./openssh-init:/custom-cont-init.d:ro
    ports:
      - '127.0.0.1:2222:2222'

  dropbear:
    image: alpine@sha256:28bd5fe8b56d1bd048e5babf5b10710ebe0bae67db86916198a6eec434943f8b
    command:
      - sh
      - -c
      - 'apk add --no-cache dropbear >/dev/null && adduser -D tester && echo "tester:testpass" | chpasswd && exec dropbear -F -E -R -p 2223'
    healthcheck:
      test: ['CMD', 'nc', '-z', '127.0.0.1', '2223']
      interval: 2s
      timeout: 2s
      retries: 30
    ports:
      - '127.0.0.1:2223:2223'

  greenmail:
    image: greenmail/standalone@sha256:e14c74ed55891afda7b9d8a8bc476af605175871b8a6dd0c5bd578f3f6db9d2b
    environment:
      GREENMAIL_OPTS: '-Dgreenmail.setup.test.all -Dgreenmail.hostname=0.0.0.0 -Dgreenmail.users=tester:testpass@localhost -Dgreenmail.verbose'
    ports:
      - '127.0.0.1:3025:3025' # smtp
      - '127.0.0.1:3465:3465' # smtps (implicit tls)
      - '127.0.0.1:3143:3143' # imap
      - '127.0.0.1:3993:3993' # imaps (implicit tls)
      - '127.0.0.1:3110:3110' # pop3
      - '127.0.0.1:3995:3995' # pop3s (implicit tls)
      - '127.0.0.1:8080:8080' # rest api (readiness)

  ws-echo:
    image: jmalloc/echo-server@sha256:86f2c45aa7e7ebe1be30b21f8cfff25a7ed6e3b059751822d4b35bf244a688d5
    environment:
      PORT: '8081'
    ports:
      - '127.0.0.1:8081:8081'

  nats:
    image: nats@sha256:7ff2e641c33dbdb0dd13a943ba0b70d841b71275c607baa53ef9b8661f0b2d8c
    # -js enables JetStream so recovery.spec can verify durable message continuity
    command:
      ['--user', 'tester', '--pass', 'testpass', '--addr', '0.0.0.0', '-js', '-sd', '/tmp/js']
    ports:
      - '127.0.0.1:4222:4222'

  ftp:
    image: stilliard/pure-ftpd@sha256:41c9aaded1fd06053c500d28415613ca7605ecc39a3e1c2ec4f0a279bd78f253
    environment:
      PUBLICHOST: '127.0.0.1'
      FTP_USER_NAME: 'tester'
      FTP_USER_PASS: 'testpass'
      FTP_USER_HOME: '/home/ftpusers/tester'
      FTP_PASSIVE_PORTS: '40000:40009'
    healthcheck:
      test: ['CMD', 'bash', '-c', 'exec 3<>/dev/tcp/127.0.0.1/21']
      interval: 3s
      timeout: 3s
      retries: 40
    ports:
      - '127.0.0.1:21:21'
      - '127.0.0.1:40000-40009:40000-40009'

  openldap:
    image: osixia/openldap@sha256:18742e9c449c9c1afe129d3f2f3ee15fb34cc43e5f940a20f3399728f41d7c28
    environment:
      LDAP_ORGANISATION: 'edgeport'
      LDAP_DOMAIN: 'example.org'
      LDAP_ADMIN_PASSWORD: 'admin'
    ports:
      - '127.0.0.1:389:389'
      - '127.0.0.1:636:636'

  ldap-seed:
    image: alpine@sha256:28bd5fe8b56d1bd048e5babf5b10710ebe0bae67db86916198a6eec434943f8b
    depends_on:
      - openldap
    volumes:
      # mount the DIRECTORY (a single-file bind mount clobbers the host file into a dir)
      - ./ldap-bootstrap:/bootstrap:ro
    command:
      - sh
      - -c
      - 'apk add --no-cache openldap-clients >/dev/null && until ldapwhoami -x -H ldap://openldap:389 -D cn=admin,dc=example,dc=org -w admin >/dev/null 2>&1; do sleep 1; done && ldapadd -c -x -H ldap://openldap:389 -D cn=admin,dc=example,dc=org -w admin -f /bootstrap/seed.ldif && echo ldap-seed-complete'
    restart: 'no'

  mqtt:
    image: eclipse-mosquitto@sha256:6f8d8a947c506f8a2290ec65cd4bd2bc7cb4d43fb5f6271f861cb013e2ef9797
    volumes:
      - ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
    ports:
      - '127.0.0.1:1883:1883'

  stomp:
    image: rmohr/activemq@sha256:b5669f141ac5c455b1010b90d348fe78289bba7e2db5659484d99736b696593c
    healthcheck:
      test: ['CMD', 'bash', '-c', 'exec 3<>/dev/tcp/127.0.0.1/8161']
      interval: 3s
      timeout: 3s
      retries: 60
    ports:
      - '127.0.0.1:61613:61613'

  syslog:
    image: alpine@sha256:28bd5fe8b56d1bd048e5babf5b10710ebe0bae67db86916198a6eec434943f8b
    command:
      - sh
      - -c
      - 'apk add --no-cache socat >/dev/null && : > /tmp/syslog.log && (socat -u TCP-LISTEN:5514,fork,reuseaddr OPEN:/tmp/syslog.log,append &) && exec socat TCP-LISTEN:5515,fork,reuseaddr SYSTEM:"cat /tmp/syslog.log"'
    healthcheck:
      test: ['CMD', 'nc', '-z', '127.0.0.1', '5515']
      interval: 2s
      timeout: 2s
      retries: 30
    ports:
      - '127.0.0.1:5514:5514' # ingest
      - '127.0.0.1:5515:5515' # readback

  smscsim:
    image: ukarim/smscsim@sha256:673ef3b2c62e3aa34be0528a9034b53e04c4fc2fbf4e65e03225717de8890707
    ports:
      - '127.0.0.1:2775:2775' # smpp
      - '127.0.0.1:12775:12775' # http MO injection

  sip:
    image: debian:bookworm-slim@sha256:7b140f374b289a7c2befc338f42ebe6441b7ea838a042bbd5acbfca6ec875818
    entrypoint: ['/bin/sh', '/entrypoint.sh']
    volumes:
      - ./sip/kamailio.cfg:/sip/kamailio.cfg:ro
      - ./sip/entrypoint.sh:/entrypoint.sh:ro
    healthcheck:
      test: ['CMD', 'bash', '-c', 'exec 3<>/dev/tcp/127.0.0.1/5060']
      interval: 3s
      timeout: 3s
      retries: 60
    ports:
      - '127.0.0.1:5060:5060/tcp' # sip over tcp (the workers transport)
      - '127.0.0.1:2855:2855/tcp' # msrp relay
