Created
August 14, 2021 12:20
-
-
Save thiagosf/a50e16d96bb6116e946e28688881a7e8 to your computer and use it in GitHub Desktop.
Nodejs + MySQL basic development structure with docker-compose
This file contains 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: | |
web: | |
image: node | |
container_name: node-project-api | |
working_dir: /var/www | |
ports: | |
- 3000:3000 | |
volumes: | |
- ./api:/var/www | |
env_file: | |
- ./api/.env | |
networks: | |
- node-project-network | |
depends_on: | |
db: | |
condition: service_healthy | |
links: | |
- db | |
- db_test | |
db: | |
image: mysql:5.7 | |
container_name: node-project-mysql | |
volumes: | |
- ./start-sql:/docker-entrypoint-initdb.d | |
- node-project-mysql-data:/var/lib/mysql | |
ports: | |
- 3306:3306 | |
networks: | |
- node-project-network | |
environment: | |
MYSQL_ROOT_PASSWORD: root | |
MYSQL_DATABASE: my_db | |
MYSQL_USER: docker | |
MYSQL_PASSWORD: docker | |
healthcheck: | |
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"] | |
interval: 2s | |
timeout: 20s | |
retries: 10 | |
db_test: | |
image: mysql:5.7 | |
container_name: node-project-mysql-test | |
ports: | |
- 3307:3306 | |
networks: | |
- node-project-network | |
environment: | |
MYSQL_ROOT_PASSWORD: root | |
MYSQL_DATABASE: my_test_db | |
MYSQL_USER: docker | |
MYSQL_PASSWORD: docker | |
networks: | |
node-project-network: | |
driver: bridge | |
volumes: | |
node-project-mysql-data: | |
driver: local |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment