Skip to content

Instantly share code, notes, and snippets.

@andrioid
Last active July 5, 2018 08:27
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 andrioid/3fe88d4b1ba84f8d84666178ebe30e96 to your computer and use it in GitHub Desktop.
Save andrioid/3fe88d4b1ba84f8d84666178ebe30e96 to your computer and use it in GitHub Desktop.
docker-compose with CompileDaemon, Postgres and go-micro
#!/bin/sh
# CompileDaemon can't handle strings with spaces in it for som reason
# So this reads the configuration and wraps it in quotes for it to work.
echo $DB_DSN
echo $DB_DRIVER
./lot --db-type="$DB_DRIVER" --db-string="$DB_DSN"
version: '3'
services:
parking-base:
image: parking-base
build: ./build/base-image
consul:
image: consul:latest
command: consul agent -dev -log-level=warn -ui -client=0.0.0.0
hostname: consul
ports:
- "8500:8500"
microweb:
image: microhq/micro
command: web --address=0.0.0.0:8080
ports:
- "8080:8080"
environment:
- MICRO_REGISTRY=consul
- MICRO_REGISTRY_ADDRESS=consul
- MICRO_API_NAMESPACE=gomicro.api
links:
- consul
db:
image: postgres:10.4
environment:
POSTGRES_USER: dev
POSTGRES_PASSWORD: localhost
POSTGRES_DB: parking
volumes:
- /tmp/parking-db:/var/lib/postgresql/data
ports:
- "5432:5432"
dbadmin:
image: adminer
environment:
- PGADMIN_DEFAULT_EMAIL=operations@parkpark.dk
- PGADMIN_DEFAULT_PASSWORD=dinmor
ports:
- "8082:8080"
depends_on:
- db
links:
- db
lot:
image: parking-base
depends_on:
- parking-base
- db
volumes:
- .:/go/src/gitlab.com/parkpark/parking
working_dir: /go/src/gitlab.com/parkpark/parking/srv/lot
environment:
- MICRO_REGISTRY=consul
- MICRO_REGISTRY_ADDRESS=consul
- DB_DRIVER=postgres
- DB_DSN=host=db user=dev password=localhost dbname=parking port=5432 sslmode=disable
command: CompileDaemon -command="./dev.sh"
links:
- consul
- db
# build/base-image/Dockerfile
FROM golang:1.10-alpine
ENV GOBIN /go/bin
RUN apk add --no-cache git
RUN go get -u github.com/golang/dep/cmd/dep && go get -u github.com/githubnemo/CompileDaemon
VOLUME ["/go/src/gitlab.com/parkpark/parking"]
@andrioid
Copy link
Author

andrioid commented Jul 3, 2018

So, I'm using this at work for my development environment... and it works for me. Putting it up here because I'll want to revisit it at some point. If it helps others too, great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment