Last active
July 5, 2018 08:27
-
-
Save andrioid/3fe88d4b1ba84f8d84666178ebe30e96 to your computer and use it in GitHub Desktop.
docker-compose with CompileDaemon, Postgres and go-micro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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!