Skip to content

Commit

Permalink
feat: Add database service templates for common database engines
Browse files Browse the repository at this point in the history
  • Loading branch information
yarlson committed Oct 25, 2024
1 parent c8198a9 commit 423629c
Showing 1 changed file with 168 additions and 0 deletions.
168 changes: 168 additions & 0 deletions pkg/config/templates/db.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
services:
postgres:
image: postgres:16-alpine
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgresuser}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeMe123}
POSTGRES_DB: ${POSTGRES_DB:-maindb}
PGDATA: /data/postgres
volumes:
- postgres-data:/data/postgres
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
interval: 10s
timeout: 5s
retries: 5

mysql:
image: mysql:8.3
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-rootpassword}
MYSQL_USER: ${MYSQL_USER:-mysqluser}
MYSQL_PASSWORD: ${MYSQL_PASSWORD:-changeMe123}
MYSQL_DATABASE: ${MYSQL_DATABASE:-maindb}
volumes:
- mysql-data:/var/lib/mysql
ports:
- "3306:3306"
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "$$MYSQL_USER", "--password=$$MYSQL_PASSWORD"]
interval: 10s
timeout: 5s
retries: 5

mariadb:
image: mariadb:11.2
environment:
MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD:-rootpassword}
MARIADB_USER: ${MARIADB_USER:-mariauser}
MARIADB_PASSWORD: ${MARIADB_PASSWORD:-changeMe123}
MARIADB_DATABASE: ${MARIADB_DATABASE:-maindb}
volumes:
- mariadb-data:/var/lib/mysql
ports:
- "3307:3306"
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "$$MARIADB_USER", "--password=$$MARIADB_PASSWORD"]
interval: 10s
timeout: 5s
retries: 5

cassandra:
image: cassandra:4.1
environment:
- CASSANDRA_CLUSTER_NAME=MyCluster
- CASSANDRA_SEEDS=cassandra
- CASSANDRA_START_RPC=true
- CASSANDRA_BROADCAST_RPC_ADDRESS=cassandra
- MAX_HEAP_SIZE=512M
- HEAP_NEWSIZE=100M
volumes:
- cassandra-data:/var/lib/cassandra
ports:
- "9042:9042" # CQL
- "7000:7000" # Internode communication
- "7199:7199" # JMX
healthcheck:
test: ["CMD-SHELL", "nodetool status | grep UN"]
interval: 30s
timeout: 10s
retries: 5
ulimits:
memlock: -1
nofile:
soft: 65536
hard: 65536

redis:
image: redis:7-alpine
volumes:
- redis-data:/data
ports:
- "6379:6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5

elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.12.0
environment:
- node.name=es01
- cluster.name=es-docker-cluster
- discovery.type=single-node
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- xpack.security.enabled=false
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- elasticsearch-data:/usr/share/elasticsearch/data
ports:
- "9200:9200"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9200"]
interval: 30s
timeout: 10s
retries: 5

kibana:
image: docker.elastic.co/kibana/kibana:8.12.0
environment:
- ELASTICSEARCH_HOSTS=http://elasticsearch:9200
ports:
- "5601:5601"

mongodb:
image: mongo:7
environment:
MONGO_INITDB_ROOT_USERNAME: ${MONGO_ROOT_USER:-mongouser}
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_ROOT_PASSWORD:-changeMe123}
volumes:
- mongodb-data:/data/db
ports:
- "27017:27017"
healthcheck:
test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/test --quiet
interval: 10s
timeout: 10s
retries: 5

clickhouse:
image: clickhouse/clickhouse-server:23.8
environment:
CLICKHOUSE_DB: ${CLICKHOUSE_DB:-default}
CLICKHOUSE_USER: ${CLICKHOUSE_USER:-default}
CLICKHOUSE_PASSWORD: ${CLICKHOUSE_PASSWORD:-changeMe123}
volumes:
- clickhouse-data:/var/lib/clickhouse
ports:
- "8123:8123"
- "9000:9000"
ulimits:
nofile:
soft: 262144
hard: 262144

solr:
image: solr:9
ports:
- "8983:8983"
volumes:
- solr-data:/var/solr

volumes:
postgres-data:
mysql-data:
mariadb-data:
cassandra-data:
redis-data:
elasticsearch-data:
mongodb-data:
clickhouse-data:
solr-data:

0 comments on commit 423629c

Please sign in to comment.