diff --git a/.github/workflows/build.dotnet.yml b/.github/workflows/build.dotnet.yml index cc8b0768c..6062c0a2f 100644 --- a/.github/workflows/build.dotnet.yml +++ b/.github/workflows/build.dotnet.yml @@ -15,7 +15,7 @@ jobs: uses: actions/checkout@v4 - name: Start containers - run: docker-compose -f "docker-compose.ci.yml" up -d + run: docker-compose --profile ci up -d - name: Setup .NET uses: actions/setup-dotnet@v4 @@ -36,4 +36,4 @@ jobs: - name: Stop containers if: always() - run: docker-compose -f "docker-compose.yml" down + run: docker-compose --profile ci down diff --git a/EventSourcing.NetCore.sln b/EventSourcing.NetCore.sln index 302298d2b..fce9100bb 100644 --- a/EventSourcing.NetCore.sln +++ b/EventSourcing.NetCore.sln @@ -28,9 +28,6 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docker", "docker", "{821D8306-C110-45AB-BDF7-AA80FDA942CE}" ProjectSection(SolutionItems) = preProject docker-compose.yml = docker-compose.yml - docker-compose.build.yml = docker-compose.build.yml - docker-compose.ci.yml = docker-compose.ci.yml - docker-compose.pg.yml = docker-compose.pg.yml Dockerfile = Dockerfile EndProjectSection EndProject diff --git a/README.md b/README.md index f2253bc51..a292f497b 100644 --- a/README.md +++ b/README.md @@ -627,7 +627,7 @@ For running the Event Store examples you need to have: 2. [Docker](https://store.docker.com/search?type=edition&offering=community) installed. Then going to the `docker` folder and running: ``` -docker-compose up +docker-compose --profile all up ``` **More information about using .NET, WebApi and Docker you can find in my other tutorials:** [WebApi with .NET](https://github.com/oskardudycz/WebApiWith.NETCore) diff --git a/Sample/ECommerce/docker/docker-compose.yml b/Sample/ECommerce/docker/docker-compose.yml index 326ee89d7..19952fb77 100644 --- a/Sample/ECommerce/docker/docker-compose.yml +++ b/Sample/ECommerce/docker/docker-compose.yml @@ -1,10 +1,11 @@ version: "3" services: postgres: - image: clkao/postgres-plv8 + image: postgres:15.1-alpine container_name: postgres environment: - POSTGRES_PASSWORD: Password12! + - POSTGRES_DB=postgres + - POSTGRES_PASSWORD=Password12! ports: - "5432:5432" networks: diff --git a/Sample/Helpdesk.Wolverine/docker-compose.yml b/Sample/Helpdesk.Wolverine/docker-compose.yml index ec3f0acf8..0ab718c0f 100644 --- a/Sample/Helpdesk.Wolverine/docker-compose.yml +++ b/Sample/Helpdesk.Wolverine/docker-compose.yml @@ -1,10 +1,11 @@ version: "3" services: postgres: - image: clkao/postgres-plv8 + image: postgres:15.1-alpine container_name: postgres environment: - POSTGRES_PASSWORD: Password12! + - POSTGRES_DB=postgres + - POSTGRES_PASSWORD=Password12! ports: - "5432:5432" networks: diff --git a/Sample/MeetingsManagement/docker/docker-compose.yml b/Sample/MeetingsManagement/docker/docker-compose.yml index 4dd660774..a3075477d 100644 --- a/Sample/MeetingsManagement/docker/docker-compose.yml +++ b/Sample/MeetingsManagement/docker/docker-compose.yml @@ -4,10 +4,11 @@ services: # Postgres ####################################################### postgres: - image: clkao/postgres-plv8 + image: postgres:15.1-alpine container_name: postgres environment: - POSTGRES_PASSWORD: Password12! + - POSTGRES_DB=postgres + - POSTGRES_PASSWORD=Password12! ports: - "5432:5432" networks: diff --git a/Sample/Warehouse.MinimalAPI/docker-compose.yml b/Sample/Warehouse.MinimalAPI/docker-compose.yml index bd7611411..4d006bc7e 100644 --- a/Sample/Warehouse.MinimalAPI/docker-compose.yml +++ b/Sample/Warehouse.MinimalAPI/docker-compose.yml @@ -4,14 +4,15 @@ services: # Postgres ####################################################### postgres: - image: clkao/postgres-plv8 + image: postgres:15.1-alpine container_name: postgres environment: - POSTGRES_PASSWORD: Password12! + - POSTGRES_DB=postgres + - POSTGRES_PASSWORD=Password12! ports: - "5432:5432" networks: - - pg_network + - postgres pgadmin: image: dpage/pgadmin4 @@ -22,10 +23,10 @@ services: ports: - "${PGADMIN_PORT:-5050}:80" networks: - - pg_network + - postgres networks: - pg_network: + postgres: driver: bridge volumes: diff --git a/Workshops/BuildYourOwnEventStore/docker/docker-compose.yml b/Workshops/BuildYourOwnEventStore/docker/docker-compose.yml index c068c5328..aa532da3e 100644 --- a/Workshops/BuildYourOwnEventStore/docker/docker-compose.yml +++ b/Workshops/BuildYourOwnEventStore/docker/docker-compose.yml @@ -1,10 +1,11 @@ version: "3" services: postgres: - image: clkao/postgres-plv8 + image: postgres:15.1-alpine container_name: postgres environment: - POSTGRES_PASSWORD: Password12! + - POSTGRES_DB=postgres + - POSTGRES_PASSWORD=Password12! ports: - "5432:5432" networks: diff --git a/Workshops/IntroductionToEventSourcing/docker-compose.yml b/Workshops/IntroductionToEventSourcing/docker-compose.yml index 5da07acb7..c73e0d128 100644 --- a/Workshops/IntroductionToEventSourcing/docker-compose.yml +++ b/Workshops/IntroductionToEventSourcing/docker-compose.yml @@ -4,14 +4,15 @@ services: # Postgres ####################################################### postgres: - image: clkao/postgres-plv8 + image: postgres:15.1-alpine container_name: postgres environment: - POSTGRES_PASSWORD: Password12! + - POSTGRES_DB=postgres + - POSTGRES_PASSWORD=Password12! ports: - "5432:5432" networks: - - pg_network + - postgres pgadmin: image: dpage/pgadmin4 @@ -22,7 +23,7 @@ services: ports: - "${PGADMIN_PORT:-5050}:80" networks: - - pg_network + - postgres ####################################################### # EventStoreDB @@ -56,7 +57,7 @@ services: networks: es_network: driver: bridge - pg_network: + postgres: driver: bridge esdb_network: driver: bridge diff --git a/docker-compose.build.yml b/docker-compose.build.yml deleted file mode 100644 index 7e661fe20..000000000 --- a/docker-compose.build.yml +++ /dev/null @@ -1,49 +0,0 @@ -version: "3" -services: - ####################################################### - # Postgres - ####################################################### - postgres: - image: clkao/postgres-plv8 - container_name: postgres - environment: - POSTGRES_PASSWORD: Password12! - ports: - - "5432:5432" - networks: - - postgres - - pgadmin: - image: dpage/pgadmin4 - container_name: pgadmin_container - environment: - PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-pgadmin4@pgadmin.org} - PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin} - PGADMIN_CONFIG_SERVER_MODE: 'False' - volumes: - - pgadmin:/var/lib/pgadmin - ports: - - "${PGADMIN_PORT:-5050}:80" - networks: - - postgres - - backend: - build: - dockerfile: Dockerfile - context: . - container_name: event_sourcing_sample - ports: - - "5555:5000" - depends_on: - postgres: - condition: service_healthy - networks: - - postgres - -networks: - postgres: - driver: bridge - -volumes: - postgres: - pgadmin: diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml deleted file mode 100644 index e0b6e6594..000000000 --- a/docker-compose.ci.yml +++ /dev/null @@ -1,88 +0,0 @@ -version: "3" -services: - ####################################################### - # Postgres - ####################################################### - postgres: - image: clkao/postgres-plv8 - container_name: postgres - environment: - POSTGRES_PASSWORD: Password12! - ports: - - "5432:5432" - networks: - - pg_network - - ####################################################### - # EventStoreDB - ####################################################### - eventstore.db: - image: eventstore/eventstore:23.10.0-bookworm-slim - # use this image if you're running ARM-based proc like Apple M1 - # image: eventstore/eventstore:23.10.0-alpha-arm64v8 - environment: - - EVENTSTORE_CLUSTER_SIZE=1 - - EVENTSTORE_RUN_PROJECTIONS=All - - EVENTSTORE_START_STANDARD_PROJECTIONS=true - - EVENTSTORE_EXT_TCP_PORT=1113 - - EVENTSTORE_HTTP_PORT=2113 - - EVENTSTORE_INSECURE=true - - EVENTSTORE_ENABLE_EXTERNAL_TCP=true - - EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP=true - ports: - - '1113:1113' - - '2113:2113' - volumes: - - type: volume - source: eventstore-volume-data - target: /var/lib/eventstore - - type: volume - source: eventstore-volume-logs - target: /var/log/eventstore - networks: - - esdb_network - - ####################################################### - # Elastic Search - ####################################################### - elasticsearch: - container_name: elastic_search - image: docker.elastic.co/elasticsearch/elasticsearch:8.13.2 - environment: - - discovery.type=single-node - - cluster.name=docker-cluster - - node.name=docker-node - - "ES_JAVA_OPTS=-Xms512m -Xmx512m" - - xpack.security.enabled=false - - xpack.security.http.ssl.enabled=false - - xpack.security.transport.ssl.enabled=false - - network.host=0.0.0.0 - - http.port=9200 - - transport.host=localhost - - bootstrap.memory_lock=true - - cluster.routing.allocation.disk.threshold_enabled=false - ulimits: - memlock: - soft: -1 - hard: -1 - volumes: - - elastic-data:/usr/share/elasticsearch/data - ports: - - "9200:9200" - - "9300:9300" - networks: - - es_network - -networks: - es_network: - driver: bridge - pg_network: - driver: bridge - esdb_network: - driver: bridge - -volumes: - postgres: - eventstore-volume-data: - eventstore-volume-logs: - elastic-data: diff --git a/docker-compose.pg.yml b/docker-compose.pg.yml deleted file mode 100644 index 008e57584..000000000 --- a/docker-compose.pg.yml +++ /dev/null @@ -1,47 +0,0 @@ -version: "3" -services: - ####################################################### - # Postgres - ####################################################### - postgres: - image: clkao/postgres-plv8 - container_name: postgres - environment: - POSTGRES_PASSWORD: Password12! - ports: - - "5432:5432" - networks: - - postgres - - pgadmin: - image: dpage/pgadmin4 - container_name: pgadmin_container - environment: - PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-pgadmin4@pgadmin.org} - PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin} - PGADMIN_CONFIG_SERVER_MODE: 'False' - volumes: - - pgadmin:/var/lib/pgadmin - ports: - - "${PGADMIN_PORT:-5050}:80" - networks: - - postgres - - jaeger: - image: jaegertracing/all-in-one:latest - ports: - - "5775:5775/udp" - - "6831:6831/udp" - - "6832:6832/udp" - - "5778:5778" - - "16686:16686" - - "14268:14268" - - "9411:9411" - -networks: - postgres: - driver: bridge - -volumes: - postgres: - pgadmin: diff --git a/docker-compose.yml b/docker-compose.yml index 7b562a88d..f55eca425 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,16 +4,19 @@ services: # Postgres ####################################################### postgres: - image: clkao/postgres-plv8 + profiles: [ postgres, postgres-all, all, all-no-ui, ci ] + image: postgres:15.1-alpine container_name: postgres environment: - POSTGRES_PASSWORD: Password12! + - POSTGRES_DB=postgres + - POSTGRES_PASSWORD=Password12! ports: - "5432:5432" networks: - - pg_network + - postgres pgadmin: + profiles: [ postgres-ui, postgres-all, all ] image: dpage/pgadmin4 container_name: pgadmin environment: @@ -22,9 +25,10 @@ services: ports: - "${PGADMIN_PORT:-5050}:80" networks: - - pg_network + - postgres jaeger: + profiles: [ otel, otel-all, all ] image: jaegertracing/all-in-one:latest ports: - "5775:5775/udp" @@ -39,6 +43,7 @@ services: # EventStoreDB ####################################################### eventstore.db: + profiles: [ eventstoredb, eventstoredb-all, all, all-no-ui, ci ] image: eventstore/eventstore:23.10.0-bookworm-slim # use this image if you're running ARM-based proc like Apple M1 # image: eventstore/eventstore:23.10.0-alpha-arm64v8 @@ -69,6 +74,7 @@ services: ####################################################### elasticsearch: image: docker.elastic.co/elasticsearch/elasticsearch:8.13.2 + profiles: [ elastic, elastic-all, all, all-no-ui, ci ] environment: - discovery.type=single-node - cluster.name=docker-cluster @@ -96,6 +102,7 @@ services: kibana: image: docker.elastic.co/kibana/kibana:8.13.2 + profiles: [ elastic-ui, elastic-all, all ] environment: - ELASTICSEARCH_HOSTS=http://elastic_search:9200 ports: @@ -105,45 +112,48 @@ services: depends_on: - elasticsearch - ####################################################### - # Zookeeper - ####################################################### - zookeeper: - image: confluentinc/cp-zookeeper:7.0.1 - hostname: zookeeper - container_name: zookeeper - networks: - - kafka_network - ports: - - "2181:2181" - environment: - ZOOKEEPER_CLIENT_PORT: 2181 - ZOOKEEPER_TICK_TIME: 2000 - ####################################################### # Kafka ####################################################### kafka: - image: confluentinc/cp-kafka:7.0.1 + image: confluentinc/confluent-local:7.6.1 + profiles: [kafka, kafka-all, all, all-no-ui] hostname: kafka container_name: kafka - depends_on: - - zookeeper networks: - kafka_network ports: - "9092:9092" + - "9091:9091" + healthcheck: + test: nc -z localhost 9092 || exit -1 + interval: 5s + timeout: 10s + retries: 100 environment: - KAFKA_BROKER_ID: 1 - KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181' - KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT + KAFKA_NODE_ID: 1 + KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: 'CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT' KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092 KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 + KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0 + KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1 + KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1 ADVERTISED_HOST_NAME: kafka KAFKA_ADVERTISED_HOSTNAME: 127.0.0.1 + KAFKA_JMX_PORT: 9101 + KAFKA_JMX_HOSTNAME: localhost + KAFKA_PROCESS_ROLES: 'broker,controller' + KAFKA_CONTROLLER_QUORUM_VOTERS: '1@kafka:29093' + KAFKA_LISTENERS: 'PLAINTEXT://kafka:29092,CONTROLLER://kafka:29093,PLAINTEXT_HOST://0.0.0.0:9092' + KAFKA_INTER_BROKER_LISTENER_NAME: 'PLAINTEXT' + KAFKA_CONTROLLER_LISTENER_NAMES: 'CONTROLLER' + KAFKA_LOG_DIRS: '/tmp/kraft-combined-logs' init-kafka: - image: confluentinc/cp-kafka:7.0.1 + image: confluentinc/confluent-local:7.6.1 + profiles: [ kafka, kafka-all, all, all-no-ui ] + hostname: init-kafka + container_name: init-kafka depends_on: - kafka entrypoint: [ '/bin/sh', '-c' ] @@ -165,46 +175,32 @@ services: " ####################################################### - # Avro Schema Registry + # Schema Registry ####################################################### schema_registry: - image: confluentinc/cp-schema-registry:7.0.1 + image: confluentinc/cp-schema-registry:7.6.1 container_name: schema_registry hostname: schema_registry + profiles: [ kafka-ui, kafka-all, all ] ports: - 8181:8181 - 8081:8081 depends_on: - - zookeeper + - kafka networks: - kafka_network environment: SCHEMA_REGISTRY_HOST_NAME: schema_registry - SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL: 'zookeeper:2181' + SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS: 'kafka:29092' SCHEMA_REGISTRY_ACCESS_CONTROL_ALLOW_METHODS: 'GET,POST,PUT,OPTIONS' SCHEMA_REGISTRY_ACCESS_CONTROL_ALLOW_ORIGIN: '*' SCHEMA_LOG4J_ROOT_LOGLEVEL: 'ERROR' SCHEMA_TOOLS_LOG4J_LOGLEVEL: 'ERROR' - kafka_rest: - image: confluentinc/cp-kafka-rest:7.0.1 - hostname: kafka_rest - ports: - - "8082:8082" - depends_on: - - schema_registry - networks: - - kafka_network - environment: - KAFKA_REST_BOOTSTRAP_SERVERS: kafka:29092 - KAFKA_REST_ZOOKEEPER_CONNECT: zookeeper:2181 - KAFKA_REST_SCHEMA_REGISTRY_URL: http://schema_registry:8081 - KAFKA_REST_HOST_NAME: kafka_rest - KAFKA_REST_LISTENERS: http://0.0.0.0:8082 - kafka_topics_ui: image: provectuslabs/kafka-ui:latest hostname: kafka-ui + profiles: [ kafka-ui, kafka-all, all ] ports: - "8080:8080" environment: @@ -213,12 +209,29 @@ services: networks: - kafka_network depends_on: - - kafka_rest + - kafka + + ####################################################### + # Test Backend Service + ####################################################### + backend: + build: + dockerfile: Dockerfile + context: . + container_name: event_sourcing_sample + profiles: [sample] + ports: + - "5555:5000" + depends_on: + postgres: + condition: service_healthy + networks: + - postgres networks: es_network: driver: bridge - pg_network: + postgres: driver: bridge esdb_network: driver: bridge