From 3f13f59c9b9ce1751822fb099f5eb164c898ea2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20H=C3=B6ck?= Date: Fri, 11 Oct 2024 09:18:57 +0200 Subject: [PATCH] chore(create): Add supported database engines and useful services to docker compose file --- packages/create/templates/docker-compose.hbs | 127 +++++++++++++------ 1 file changed, 88 insertions(+), 39 deletions(-) diff --git a/packages/create/templates/docker-compose.hbs b/packages/create/templates/docker-compose.hbs index ba40e4c5f2..438a32cbe9 100644 --- a/packages/create/templates/docker-compose.hbs +++ b/packages/create/templates/docker-compose.hbs @@ -1,40 +1,89 @@ -version: "3" +# INFORMATION +# We are not exposing the default ports for the services in this file. +# This is to avoid conflicts with existing services on your machine. +# In case you don't have any services running on the default ports, you can expose them by changing the +# ports section in the services block. Please don't forget to update the ports in the .env file as well. + services: - server: - build: - context: . - dockerfile: Dockerfile - ports: - - 3000:3000 - command: ["npm", "run", "start:server"] - volumes: - - /usr/src/app - environment: - DB_HOST: database - DB_PORT: 5432 - DB_NAME: {{{ escapeSingle dbName }}} - DB_USERNAME: {{{ escapeSingle dbUserName }}} - DB_PASSWORD: {{{ escapeSingle dbPassword }}} - worker: - build: - context: . - dockerfile: Dockerfile - command: ["npm", "run", "start:worker"] - volumes: - - /usr/src/app - environment: - DB_HOST: database - DB_PORT: 5432 - DB_NAME: {{{ escapeSingle dbName }}} - DB_USERNAME: {{{ escapeSingle dbUserName }}} - DB_PASSWORD: {{{ escapeSingle dbPassword }}} - database: - image: postgres - volumes: - - /var/lib/postgresql/data - ports: - - 5432:5432 - environment: - POSTGRES_DB: {{{ escapeSingle dbName }}} - POSTGRES_USER: {{{ escapeSingle dbUserName }}} - POSTGRES_PASSWORD: {{{ escapeSingle dbPassword }}} + postgres_db: + image: postgres:16-alpine + volumes: + - postgres_db_data:/var/lib/postgresql/data + ports: + - "6543:5432" + environment: + POSTGRES_DB: {{{ escapeSingle dbName }}} + POSTGRES_USER: {{{ escapeSingle dbUserName }}} + POSTGRES_PASSWORD: {{{ escapeSingle dbPassword }}} + + mysql_db: + image: mysql:8 + volumes: + - mysql_db_data:/var/lib/mysql + environment: + MYSQL_ROOT_PASSWORD: {{{ escapeSingle dbRootPassword }}} + MYSQL_DATABASE: {{{ escapeSingle dbName }}} + MYSQL_USER: {{{ escapeSingle dbUserName }}} + MYSQL_PASSWORD: {{{ escapeSingle dbPassword }}} + ports: + - "4306:3306" + + mariadb_db: + image: mariadb:10 + volumes: + - mariadb_db_data:/var/lib/mysql + environment: + MARIADB_ROOT_PASSWORD: {{{ escapeSingle dbRootPassword }}} + MARIADB_DATABASE: {{{ escapeSingle dbName }}} + MARIADB_USER: {{{ escapeSingle dbUserName }}} + MARIADB_PASSWORD: {{{ escapeSingle dbPassword }}} + ports: + - "3306:3306" + + # RECOMMENDED (especially for production) + # Want to use our BullMQ with Redis instead of our default database job queue? + # Checkout our BullMQ plugin: https://docs.vendure.io/reference/core-plugins/job-queue-plugin/bull-mqjob-queue-plugin/ + redis: + image: redis:7-alpine + ports: + - "6479:6379" + volumes: + - redis_data:/data + + # RECOMMENDED + # Want to use Typesense instead of our default search engine? + # Checkout our advanced search plugin: https://vendure.io/hub/vendure-plus-advanced-search-plugin + # To run the typesense container run "docker compose up -d typesense" + typesense: + image: typesense/typesense:27 + command: [ '--data-dir', '/data', '--api-key', 'SuperSecret' ] + ports: + - "8208:8108" + volumes: + - typesense_data:/data + + # Want to use Elasticsearch instead of our default database engine? + # Checkout our Elasticsearch plugin: https://docs.vendure.io/reference/core-plugins/elasticsearch-plugin/ + # To run the elasticsearch container run "docker compose up -d elasticsearch" + elasticsearch: + image: docker.elastic.co/elasticsearch/elasticsearch:7.1.1 + env: + discovery.type: single-node + bootstrap.memory_lock: true + ES_JAVA_OPTS: -Xms512m -Xmx512m + volumes: + - elasticsearch_data:/usr/share/elasticsearch/data + ports: + - "9300:9200" + +volumes: + postgres_db_data: + driver: local + mysql_db_data: + driver: local + typesense_data: + driver: local + elasticsearch_data: + driver: local + redis_data: + driver: local