-
-
Save yashodhank/b0862cc36e1c512dded303019ccce428 to your computer and use it in GitHub Desktop.
Cheat Sheet about Docker Compose For Database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
db: | |
image: mongo:4.0 | |
restart: always | |
environment: | |
MONGO_INITDB_ROOT_USERNAME: root | |
MONGO_INITDB_ROOT_PASSWORD: root | |
ports: | |
- 27017:27017 | |
volumes: | |
- mongo:/data/db | |
mongo-seed: | |
image: mongo:4.0 | |
command: bash -c "chmod +x /init_mongo.sh && /init_mongo.sh" | |
environment: | |
MONGO_SEED_ON: 1 | |
MONGO_SEED_PATH: /seed | |
MONGO_HOST: db | |
MONGO_PORT: 27017 | |
MONGO_ROOT_USERNAME: root | |
MONGO_ROOT_PASSWORD: root | |
MONGO_AUTH_DATABASE: admin | |
MONGO_DATABASE: test_db | |
volumes: | |
- ./mongo/seed:/seed | |
- ./mongo/init_mongo_auth.sh:/init_mongo_auth.sh | |
depends_on: | |
- db | |
mongo-express: | |
image: mongo-express | |
restart: always | |
ports: | |
- 8081:8081 | |
environment: | |
ME_CONFIG_MONGODB_SERVER: db | |
ME_CONFIG_MONGODB_PORT: 27017 | |
ME_CONFIG_MONGODB_ADMINUSERNAME: root | |
ME_CONFIG_MONGODB_ADMINPASSWORD: root | |
depends_on: | |
- db | |
volumes: | |
mongo: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
db: | |
image: mongo:4.0 | |
restart: always | |
ports: | |
- 27017:27017 | |
volumes: | |
- mongo:/data/db | |
mongo-seed: | |
image: mongo:4.0 | |
command: bash -c "chmod +x /init_mongo.sh && /init_mongo.sh" | |
environment: | |
MONGO_SEED_ON: 1 | |
MONGO_SEED_PATH: /seed | |
MONGO_HOST: db | |
MONGO_PORT: 27017 | |
MONGO_DATABASE: test_db | |
volumes: | |
- ./mongo/seed:/seed | |
- ./mongo/init_mongo.sh:/init_mongo.sh | |
depends_on: | |
- db | |
mongo-express: | |
image: mongo-express | |
restart: always | |
ports: | |
- 8081:8081 | |
environment: | |
ME_CONFIG_MONGODB_SERVER: db | |
ME_CONFIG_MONGODB_PORT: 27017 | |
depends_on: | |
- db | |
volumes: | |
mongo: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
db: | |
image: mysql:8.0 | |
command: --default-authentication-plugin=mysql_native_password | |
restart: always | |
environment: | |
TZ: "Etc/UTC" | |
MYSQL_ROOT_PASSWORD: root | |
MYSQL_DATABASE: test_db | |
MYSQL_USER: test | |
MYSQL_PASSWORD: test | |
ports: | |
- 3306:3306 | |
volumes: | |
- mysql:/var/lib/mysql | |
- ./mysql/initdb:/docker-entrypoint-initdb.d | |
# Choise 1: Standard Admin | |
phpmyadmin: | |
image: phpmyadmin/phpmyadmin | |
restart: always | |
ports: | |
- 8080:80 | |
environment: | |
PMA_ARBITRARY: 1 | |
PMA_HOST: db | |
PMA_USER: root | |
PMA_PASSWORD: root | |
depends_on: | |
- db | |
# Choise 2: Light-weight Admin | |
# adminer: | |
# image: adminer | |
# restart: always | |
# ports: | |
# - 8080:8080 | |
# depends_on: | |
# - db | |
volumes: | |
mysql: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
db: | |
image: postgres:11.4-alpine | |
restart: always | |
environment: | |
POSTGRES_INITDB_ARGS: "--encoding=UTF-8 --locale=C" | |
TZ: "Etc/UTC" # "Asia/Tokyo" | |
POSTGRES_USER: test | |
POSTGRES_PASSWORD: test | |
POSTGRES_DB: test_db | |
ports: | |
- 5432:5432 | |
volumes: | |
- postgres:/var/lib/postgresql/data | |
- ./postgres/initdb:/docker-entrypoint-initdb.d | |
# Choise 1: Standard Admin | |
pgadmin: | |
image: dpage/pgadmin4 | |
restart: always | |
ports: | |
- 8080:80 | |
environment: | |
PGADMIN_DEFAULT_EMAIL: [email protected] | |
PGADMIN_DEFAULT_PASSWORD: admin | |
volumes: | |
- pgadmin:/var/lib/pgadmin | |
depends_on: | |
- db | |
# Choise 2: Light-weight Admin | |
# adminer: | |
# image: adminer | |
# restart: always | |
# ports: | |
# - 8080:8080 | |
# depends_on: | |
# - db | |
volumes: | |
postgres: | |
pgadmin: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
prisma: | |
image: prismagraphql/prisma:1.34 | |
restart: always | |
ports: | |
- "4466:4466" | |
environment: | |
PRISMA_CONFIG: | | |
port: 4466 | |
# uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security | |
# managementApiSecret: my-secret | |
databases: | |
default: | |
connector: mysql | |
host: mysql | |
user: root | |
password: prisma | |
rawAccess: false # Disable to fix https://github.com/prisma/prisma-admin-feedback/issues/130 | |
port: 3306 | |
migrations: false # Disable to fix https://github.com/prisma/prisma-admin-feedback/issues/130 | |
mysql: | |
image: mysql:5.7 | |
restart: always | |
ports: | |
- "3306:3306" | |
environment: | |
MYSQL_ROOT_PASSWORD: prisma | |
volumes: | |
- mysql:/var/lib/mysql | |
phpmyadmin: | |
image: phpmyadmin/phpmyadmin | |
restart: always | |
ports: | |
- "8080:80" | |
environment: | |
PMA_ARBITRARY: 1 | |
PMA_HOST: mysql | |
PMA_USER: root | |
PMA_PASSWORD: prisma | |
depends_on: | |
- mysql | |
volumes: | |
mysql: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# MONGO_SEED_ON is equal to 1 as default | |
if [ ${MONGO_SEED_ON:-1} -eq 0 ]; then | |
echo "No seed imported." | |
exit 0 | |
fi | |
# NOTE: Each JSON file name must show each collection name | |
for file in `\find "$MONGO_SEED_PATH" -name "*.json" -maxdepth 1`; do | |
mongoimport --host "$MONGO_HOST:$MONGO_PORT" --db "$MONGO_DATABASE" --type json --file "$file" --jsonArray | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# MONGO_SEED_ON is equal to 1 as default | |
if [ ${MONGO_SEED_ON:-1} -eq 0 ]; then | |
echo "No seed imported." | |
exit 0 | |
fi | |
# NOTE: Each JSON file name must show each collection name | |
for file in `\find "$MONGO_SEED_PATH" -name "*.json" -maxdepth 1`; do | |
mongoimport --host "$MONGO_HOST:$MONGO_PORT" --username "$MONGO_ROOT_USERNAME" --password "$MONGO_ROOT_PASSWORD" --authenticationDatabase "$MONGO_AUTH_DATABASE" --db "$MONGO_DATABASE" --type json --file "$file" --jsonArray | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
endpoint: http://localhost:4466 | |
datamodel: datamodel.prisma | |
generate: | |
- generator: javascript-client | |
output: ./generated/prisma-client/ | |
seed: | |
import: seed.graphql | |
hooks: | |
post-deploy: | |
- prisma generate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment