Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add explicit (separate) "docker-swarm" and "triton" docker-compose files #9

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 34 additions & 30 deletions common-compose.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,39 @@
# MySQL designed for container-native deployment on Joyent's Triton platform.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we'd eliminate the common-compose.yml entirely. We dropped it in our more recent blueprints because eliminating the use of --link for Consul meant that the main docker-compose.yml could be the common parent. https://github.com/autopilotpattern/couchbase is a good example.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, I've started work on fixing up this repo in #14


mysql:
image: autopilotpattern/mysql:latest
mem_limit: 4g
restart: always
env_file: _env
environment:
- CONTAINERBUDDY=file:///etc/containerbuddy.json
- MANTA_PRIVATE_KEY
version: '2'

# expose for linking, but each container gets a private IP for
# internal use as well
expose:
- 3306
services:

# ---------------------------------------------------
# Consul as a service discovery tier
mysql:
image: autopilotpattern/mysql:latest
mem_limit: 4g
restart: always
env_file: _env
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth noting here that _env becomes relative to the repo root, so all subdirectories share a single _env file, which may or may not be a good idea long term (since I found in my own testing that having my local Swarm try to use the same Manta bucket as a cluster running on Triton caused headaches due to restoring the Triton cluster's and thus fighting over the bucket).

environment:
- CONTAINERBUDDY=file:///etc/containerbuddy.json
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason we don't just embed CONTAINERBUDDY=file:///etc/containerbuddy.json directly in the image itself?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right to ask. That's what we've started doing since this one. Example: https://github.com/autopilotpattern/couchbase/blob/master/Dockerfile#L12

- MANTA_PRIVATE_KEY

consul:
image: progrium/consul:latest
command: -server -bootstrap -ui-dir /ui
restart: always
mem_limit: 128m
ports:
- 8500
expose:
- 53
- 8300
- 8301
- 8302
- 8400
- 8500
dns:
- 127.0.0.1
# expose for linking, but each container gets a private IP for
# internal use as well
expose:
- 3306

# ---------------------------------------------------
# Consul as a service discovery tier

consul:
image: progrium/consul:latest
command: -server -bootstrap -ui-dir /ui
restart: always
mem_limit: 128m
ports:
- 8500
expose:
- 53
- 8300
- 8301
- 8302
- 8400
- 8500
dns:
- 127.0.0.1
11 changes: 0 additions & 11 deletions docker-compose.yml

This file was deleted.

1 change: 1 addition & 0 deletions docker-swarm/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
COMPOSE_PROJECT_NAME=autopilotmysql
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to drop these .env files, but they make our container names default to autopilotmysql_XXX_N instead of dockerswarm_XXX_N (due to the subdirectory name).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compose automatically loads the .env file? TIL.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very interesting

13 changes: 13 additions & 0 deletions docker-swarm/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '2'

services:

mysql:
extends:
file: ../common-compose.yml
service: mysql

consul:
extends:
file: ../common-compose.yml
service: consul
1 change: 1 addition & 0 deletions triton/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
COMPOSE_PROJECT_NAME=autopilotmysql
17 changes: 17 additions & 0 deletions triton/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: '2'

services:

mysql:
extends:
file: ../common-compose.yml
service: mysql
network_mode: bridge
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using an explicit network_mode: bridge here is what lets this version: '2' file still work on Triton (since no containers are using the default network, it doesn't get auto-created).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL. Thank you.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤘

links:
- consul:consul

consul:
extends:
file: ../common-compose.yml
service: consul
network_mode: bridge