-
-
Save jimmy947788/20bb540fef6d91b15d232297341f9e15 to your computer and use it in GitHub Desktop.
docker-comose template
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
COMPOSE_PROJECT_NAME=myproject | |
# Redis | |
REDIS_HOSTNAME=redisdb.local | |
REDIS_PORT=6379 | |
REDIS_PASSWORD= | |
# Rabbitmq | |
RABBITMQ_HOSTNAME=rabbitmq.local | |
RABBITMQ_USERNAME=root | |
RABBITMQ_PASSWORD=123 | |
RABBITMQ_PORT=5672 | |
RABBITMQ_VHOST=/ | |
RABBITMQ_WEB_PORT=15672 | |
# MARIADB | |
MARIADB_HOSTNAME=mariadb.local | |
MARIADB_PORT=3306 | |
MARIADB_DATABASE=edetector | |
MARIADB_USER=edetector | |
MARIADB_PASSWORD=edetector123 | |
MARIADB_ROOT_PASSWORD=root123 | |
# pywebsite | |
MYAPP_HOSTNAME=myapp.local | |
FLASK_RUN_HOST=0.0.0.0 | |
FLASK_RUN_PORT=8000 | |
FLASK_API_TOKEN=ciDeUDL5J3lYlue5qUcIlmO3o1Y1OkybWdohts8Err0q5ROgy2IwdW1sg5bLKeTefpYR2DqCugiveJC4K5YLiXnJe1iXN2SCOItOBwnsn2RP4e3B282uSwcD3Jw3ylE8 | |
SECRET_KEY=2b2c5a243c2be6f0e3782e4e6408a610 | |
# flower | |
FLOWER_HOSTNAME=flower.local | |
FLOWER_PORT=5555 |
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.4' | |
services: | |
myapp: | |
environment: | |
- APP_ENV=development | |
- ENABLE_DEBUG=1 # 啟動 debug 模式 (0: 關閉, 1: 開啟) | |
ports: | |
- 5678:5678 | |
volumes: | |
- ./myapp:/usr/local/myapp | |
env_file: ./.env #這裡才正式把環境變數帶進來 |
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.4' | |
services: | |
myapp: | |
image: myapp:1.00 | |
container_name: ${MYAPP_HOSTNAME} | |
build: | |
context: ./ | |
dockerfile: ./myapp/Dockerfile | |
args: | |
- FLASK_RUN_HOST=${FLASK_RUN_HOST} | |
- FLASK_RUN_PORT=${FLASK_RUN_PORT} | |
restart: unless-stopped | |
ports: | |
- ${FLASK_RUN_PORT}:${FLASK_RUN_PORT} | |
volumes: | |
- ./logs:/logs | |
healthcheck: | |
test: curl --fail http://localhost:${FLASK_RUN_PORT}/version || exit 1 | |
interval: 10s | |
timeout: 100s | |
retries: 15 | |
#start_period: 20s | |
depends_on: | |
rabbitmq: | |
condition: service_healthy | |
mariadb: | |
condition: service_healthy | |
redisdb: | |
condition: service_healthy | |
env_file: ./.env #這裡才正式把環境變數帶進來 |
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.4' | |
services: | |
mariadb: | |
image: mariadb:10-jammy | |
container_name: ${MARIADB_HOSTNAME} | |
environment: | |
MARIADB_DATABASE: ${MARIADB_DATABASE} | |
MARIADB_USER: "${MARIADB_USER}" | |
MARIADB_PASSWORD: "${MARIADB_PASSWORD}" | |
MARIADB_ROOT_PASSWORD: "${MARIADB_ROOT_PASSWORD}" | |
volumes: | |
- ./.volumes/mariadb:/var/lib/mariadb | |
- ./.volumes/conf:/etc/mariadb/conf.d | |
#- ./SQLScripts:/docker-entrypoint-initdb.d #初始化腳本-第一次跑起來container會執行 | |
ports: | |
- ${MARIADB_PORT}:${MARIADB_PORT} | |
restart: always | |
healthcheck: | |
test: ["CMD-SHELL", "mysqladmin ping -P ${MARIADB_PORT} -u${MARIADB_USER} -p${MARIADB_PASSWORD} | grep 'mysqld is alive' || exit 1"] | |
interval: 10s | |
timeout: 2s | |
retries: 3 | |
env_file: .env #這裡才正式把環境變數帶進來 | |
rabbitmq: | |
image: rabbitmq:3-management-alpine | |
container_name: ${RABBITMQ_HOSTNAME} | |
volumes: | |
- ./.volumes/conf:/etc/rabbitmq/rabbitmq.conf:ro | |
ports: | |
- ${RABBITMQ_WEB_PORT}:${RABBITMQ_WEB_PORT} | |
- ${RABBITMQ_PORT}:${RABBITMQ_PORT} | |
restart: always | |
environment: | |
RABBITMQ_DEFAULT_USER: "${RABBITMQ_USERNAME}" | |
RABBITMQ_DEFAULT_PASS: "${RABBITMQ_PASSWORD}" | |
RABBITMQ_DEFAULT_VHOST: "${RABBITMQ_VHOST}" | |
healthcheck: | |
test: rabbitmq-diagnostics -q ping | |
interval: 10s | |
timeout: 30s | |
retries: 3 | |
env_file: .env #這裡才正式把環境變數帶進來 | |
redisdb: | |
image: redis:7-alpine | |
container_name: ${REDIS_HOSTNAME} | |
volumes: | |
- ./.volumes/conf:/redis.conf:ro | |
ports: | |
- ${REDIS_PORT}:${REDIS_PORT} | |
command: ["redis-server", "/redis.conf"] | |
restart: always | |
healthcheck: | |
test: ["CMD", "redis-cli", "-p", "${REDIS_PORT}", "ping"] | |
interval: 10s | |
timeout: 10s | |
retries: 3 | |
env_file: .env #這裡才正式把環境變數帶進來 | |
flower: | |
image: mher/flower:1.2 | |
container_name: ${FLOWER_HOSTNAME} | |
environment: | |
- CELERY_BROKER_URL=amqp://${RABBITMQ_USERNAME}:${RABBITMQ_PASSWORD}@${RABBITMQ_HOSTNAME}:${RABBITMQ_PORT}/${RABBITMQ_VHOST} | |
- CELERY_RESULT_BACKEND=redis://${REDIS_HOSTNAME}:${REDIS_PORT}/1 | |
#- FLOWER_PORT=${FLOWER_PORT} | |
ports: | |
- ${FLOWER_PORT}:${FLOWER_PORT} | |
depends_on: | |
rabbitmq: | |
condition: service_healthy | |
redisdb: | |
condition: service_healthy | |
env_file: .env #這裡才正式把環境變數帶進來 |
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
// path in the workspace to the .vscode/tasks.json file | |
{ | |
"version": "2.0.0", | |
"tasks": [ | |
{ | |
"label": "Run Flask docker-compose up", | |
"type": "docker-compose", | |
"dockerCompose": { | |
"up": { | |
"detached": true, | |
"build": true, | |
}, | |
"envFiles": [ | |
"${workspaceFolder}/.env" | |
], | |
"files": [ | |
"${workspaceFolder}/docker-compose.common.yml", | |
"${workspaceFolder}/docker-compose.debug.yml", | |
"${workspaceFolder}/docker-compose.yml" | |
], | |
}, | |
"problemMatcher": [], | |
"group": { | |
"kind": "build", | |
"isDefault": true | |
}, | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment