Skip to content

Commit

Permalink
improve: better docker-compose file
Browse files Browse the repository at this point in the history
  • Loading branch information
christiangda committed Nov 25, 2021
1 parent 9b110eb commit 748ded6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 38 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ This is a close image of how it works:
* [Golang](https://golang.org/pkg/net/http/pprof/) `pprof` enabled via `--profile` command line when starting the service
* Prometheus metrics for consumers, storage workers, go statistics, and database
* [Grafana](https://grafana.com/) dashboard for [Prometheus.io](https://prometheus.io/) metrics
* Dockerfile multi-stage build
* [Dockerfile](Dockerfile) multi-stage build
* Makefile to facilitate the project builds
* [docker-compose file](https://github.com/christiangda/mq-to-db/blob/master/docker-compose.yaml) and [configuration](https://github.com/christiangda/mq-to-db/tree/master/docker-compose) to testing all elements
* docker images at [docker-hub](https://hub.docker.com/repository/docker/christiangda/mq-to-db) and [Github Packages](https://github.com/christiangda/mq-to-db/packages)
Expand Down Expand Up @@ -117,10 +117,10 @@ docker stop postgresql
```bash
git clone https://github.com/christiangda/mq-to-db.git
cd mq-to-db/
go run -race ./cmd/mq-to-db/main.go --help
go run -race ./cmd/mq-to-db/main.go --help

# and then
go run -race ./cmd/mq-to-db/main.go --configFile config-sample.yaml
go run -race ./cmd/mq-to-db/main.go --configFile config-sample.yaml
```

__NOTE:__ the parameter `-race`is to check [race conditions](https://blog.golang.org/race-detector) because we are using [Go Concurrency](https://blog.golang.org/pipelines)
Expand Down Expand Up @@ -153,7 +153,7 @@ Here I use `master tag`, but you can see all [releases here](https://hub.docker.
docker pull christiangda/mq-to-db:master

# see available option
docker run --rm --name mq-to-db christiangda/mq-to-db:master - --help
docker run --rm --name mq-to-db christiangda/mq-to-db:master - --help

# run with a config file mapped and with profile option
docker run --rm -v <path to config file>:/etc/mq-to-db/config.yaml --name mq-to-db christiangda/mq-to-db:master - --profile
Expand Down Expand Up @@ -192,7 +192,7 @@ make
__NOTES__ related to make

* 1. This create a cross-compiling binaries and also Docker Image (linux 64bits)
* 2. Check the [Makefile](Makefile) to see the `The make available targets options`
* 2. Check the [Makefile](Makefile) to see `The make available targets options`

## References

Expand Down
68 changes: 35 additions & 33 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,39 +1,41 @@
---
version: "3.5"

# volumes:
# prometheus_data: {}
# grafana_data: {}
# postgresql_data: {}
# rabbitmq_data: {}
volumes:
prometheus_data: {}
grafana_data: {}
postgresql_data: {}
rabbitmq_data: {}

# networks:
# development:
networks:
development:

services:
# Database
postgresql:
container_name: postgresql
privileged: true
image: postgres:11
network_mode: bridge
# networks:
# - development
image: postgres:9.6.24
#privileged: true
#network_mode: bridge
networks:
- development
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: mysecretpassword
POSTGRES_DB: postgres
ports:
- 5432:5432
volumes:
- postgresql_data:/var/lib/postgresql/data
restart: always

# Queue system
rabbitmq:
container_name: rabbitmq
image: rabbitmq:3-management
network_mode: bridge
# networks:
# - development
#network_mode: bridge
networks:
- development
ports:
- 5672:5672
- 15672:15672
Expand All @@ -43,17 +45,17 @@ services:
prometheus:
container_name: prometheus
image: prom/prometheus:v2.26.0
privileged: true
network_mode: bridge
# networks:
# - development
#privileged: true
#network_mode: bridge
networks:
- development
links:
- mq-to-db-01
- mq-to-db-02
user: root
volumes:
- ./docker-compose/prometheus/:/etc/prometheus/:Z
#- prometheus_data:/prometheus
- prometheus_data:/prometheus
command:
- "--config.file=/etc/prometheus/prometheus.yml"
ports:
Expand All @@ -63,10 +65,10 @@ services:
grafana:
container_name: grafana
image: grafana/grafana:7.5.4
privileged: true
network_mode: bridge
# networks:
# - development
#privileged: true
#network_mode: bridge
networks:
- development
links:
- prometheus
environment:
Expand All @@ -75,7 +77,7 @@ services:
volumes:
- ./docker-compose/grafana/provisioning/:/etc/grafana/provisioning/
- ./docker-compose/grafana/dashboards/:/grafana/dashboards/mq-to-db/:Z
#- grafana_data:/var/lib/grafana
- grafana_data:/var/lib/grafana
ports:
- 3000:3000
depends_on:
Expand All @@ -85,10 +87,10 @@ services:
# mq-to-db
mq-to-db-01:
container_name: mq-to-db-01
privileged: true
network_mode: bridge
# networks:
# - development
#privileged: true
#network_mode: bridge
networks:
- development
build:
dockerfile: Dockerfile
context: ./
Expand Down Expand Up @@ -117,10 +119,10 @@ services:

mq-to-db-02:
container_name: mq-to-db-02
privileged: true
network_mode: bridge
# networks:
# - development
#privileged: true
#network_mode: bridge
networks:
- development
build:
dockerfile: Dockerfile
context: ./
Expand Down

0 comments on commit 748ded6

Please sign in to comment.