Skip to content

Instantly share code, notes, and snippets.

@matt-halliday
Created August 1, 2017 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matt-halliday/ee0eb2e1acf8c34e1c929b80251b49f3 to your computer and use it in GitHub Desktop.
Save matt-halliday/ee0eb2e1acf8c34e1c929b80251b49f3 to your computer and use it in GitHub Desktop.
Ensure MySQL is ready without some dirty bash script trying to connect
version: "2.1"
services:
app:
build:
dockerfile: ./build/docker/app/Dockerfile
context: .
env_file:
- ./build/docker/app/app.env
- ./build/docker/mysql/mysql.env
extra_hosts:
- app.docker:127.0.0.1
ports:
- 80:80
restart: always
depends_on:
db:
condition: service_healthy
db:
build:
dockerfile: ./build/docker/mysql/Dockerfile
context: .
env_file:
- ./build/docker/mysql/mysql.env
ports:
- 3306:3306
healthcheck:
test: ["CMD", "nc", "-z", "localhost", "3306"]
interval: 2s
timeout: 3s
retries: 15
FROM mysql:5.7.16
RUN apt-get update \
&& apt install -y netcat \
&& apt-get clean && apt-get purge \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment