version: '2'

# # register id/pass to the database volume(registry2_authdb)
# > docker-compose run --rm register_user
# # boot up docker registry container
# > docker-compose up -d registry
# # you can execute examples (and docker-login too)
# > ./target/debug/examples/push

services:
  iostream:
    build:
      context: ./docker/attach
    image: test-iostream:latest

  signal:
    build:
      context: ./docker/signal
    image: test-signal:latest


  # Docker registry container.
  # This service is used for examples/login and auth.
  registry:
    image: registry:2
    container_name: registry2
    environment:
      REGISTRY_AUTH: htpasswd
      REGISTRY_AUTH_HTPASSWD_REALM: Registry Realm
      REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd
    volumes:
      - registry2_authdb:/auth
    ports:
      - 5000:5000
    restart: always
    networks:
      - default

  # User password db generator for basic authentication.
  register_user:
    image: registry:2
    environment:
      REGISTRY_USER: "someusername"
      REGISTRY_PASSWORD: "somepassword"
    volumes:
      - registry2_authdb:/auth
    command: |
      sh -c "htpasswd -Bbn $${REGISTRY_USER} $${REGISTRY_PASSWORD} >> /auth/htpasswd"

volumes:
    registry2_authdb:

