Skip to content

Instantly share code, notes, and snippets.

@hans
Created June 15, 2021 21:57
Show Gist options
  • Save hans/e91b9b73a8335f1e2d0415bd8c1e5015 to your computer and use it in GitHub Desktop.
Save hans/e91b9b73a8335f1e2d0415bd8c1e5015 to your computer and use it in GitHub Desktop.
nodejs + mysql compose setup
version: '3'
services:
app:
image: node:latest
restart: on-failure
depends_on:
- db
ports: # map container ports to host ports. format is <HOST_PORT>:<CONTAINER_PORT>
- "12367:80"
volumes:
- ./server:/server # Mounts your nodejs server code at the container location /server
# Define the command to start the server code
command: node /server/run.js
# Defines a database service. You can connect to the service
# from `app` by simply connecting to the hostname `db`
db:
image: mysql:latest
volumes:
- ./data/db:/var/lib/mysql # mounts MySQL data directory within the container to host directory `./data/db`
restart: on-failure
environment:
MYSQL_ROOT_PASSWORD: abc
MYSQL_DATABASE: mydb
MYSQL_USER: admin
MYSQL_PASSWORD: password
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment