From 48d78ec0ab9d39bff085d047a355e23d65067665 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Thu, 14 Jan 2021 16:32:01 +0100 Subject: [PATCH] chore: improve docker-compose setup Signed-off-by: Mark Sagi-Kazar --- .gitignore | 1 + Makefile | 12 ++++++++++++ docker-compose.override.yaml.dist | 14 ++++++++++++++ docker-compose.yaml | 6 ------ 4 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 docker-compose.override.yaml.dist diff --git a/.gitignore b/.gitignore index 29a47eb6..f6cd2e19 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /.idea/ /bin/ +/docker-compose.override.yaml /vendor/ diff --git a/Makefile b/Makefile index 65042522..82b266a6 100644 --- a/Makefile +++ b/Makefile @@ -40,6 +40,18 @@ bin/example-app: release-binary: @go build -o /go/bin/dex -v -ldflags $(LD_FLAGS) $(REPO_PATH)/cmd/dex +docker-compose.override.yaml: + cp docker-compose.override.yaml.dist docker-compose.override.yaml + +.PHONY: up +up: docker-compose.override.yaml ## Launch the development environment + @ if [ docker-compose.override.yaml -ot docker-compose.override.yaml.dist ]; then diff -u docker-compose.override.yaml docker-compose.override.yaml.dist || (echo "!!! The distributed docker-compose.override.yaml example changed. Please update your file accordingly (or at least touch it). !!!" && false); fi + docker-compose up -d + +.PHONY: down +down: clear ## Destroy the development environment + docker-compose down --volumes --remove-orphans --rmi local + test: bin/test/kube-apiserver bin/test/etcd @go test -v ./... diff --git a/docker-compose.override.yaml.dist b/docker-compose.override.yaml.dist new file mode 100644 index 00000000..8b4276d7 --- /dev/null +++ b/docker-compose.override.yaml.dist @@ -0,0 +1,14 @@ +version: "3.8" + +services: + mysql: + ports: + - "127.0.0.1:3306:3306" + + postgres: + ports: + - "127.0.0.1:5432:5432" + + etcd: + ports: + - "127.0.0.1:2379:2379" diff --git a/docker-compose.yaml b/docker-compose.yaml index 4a3bb8ee..91e58c3f 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -16,8 +16,6 @@ services: MYSQL_USER: mysql MYSQL_PASSWORD: mysql MYSQL_ROOT_PASSWORD: root - ports: - - "127.0.0.1:3306:3306" postgres: image: postgres:10.15 @@ -25,16 +23,12 @@ services: POSTGRES_DB: dex POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres - ports: - - "127.0.0.1:5432:5432" etcd: image: gcr.io/etcd-development/etcd:v3.4.9 environment: ETCD_LISTEN_CLIENT_URLS: http://0.0.0.0:2379 ETCD_ADVERTISE_CLIENT_URLS: http://0.0.0.0:2379 - ports: - - "127.0.0.1:2379:2379" # For testing the Kubernetes storage backend we suggest https://kind.sigs.k8s.io/: # kind create cluster