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

harden docker-compose #298

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
DATABASE_URL=postgres://postgres:password@postgres:5433/namada-indexer
POSTGRES_PASSWORD=
TENDERMINT_URL=http://host.docker.internal:26657
CACHE_URL=redis://dragonfly:6379
WEBSERVER_PORT=5001
DATABASE_URL_TEST=postgres://postgres:[email protected]:5433
# Binds the webserver's port to the localhost by default. if you need to make it public bind it to 0.0.0.0 or your server IP
WEBSERVER_HOST_IP=127.0.0.1
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ rust-project.json
# End of https://www.toptal.com/developers/gitignore/api/osx,git,macos,rust-analyzer,rust

.vscode
.idea

swagger-codegen.json

# Ignore docker compose override files
docker-compose.override*
overrides
33 changes: 0 additions & 33 deletions docker-compose-db.yml

This file was deleted.

84 changes: 53 additions & 31 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,66 @@
name: ${NAMADA_INDEXER_PROJECT_NAME:-namada-indexer}
x-defaults: &defaults
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
dragonfly:
condition: service_healthy
postgres:
condition: service_healthy
dragonfly:
condition: service_healthy
build: &build
context: .
dockerfile: Dockerfile
args: &build-args
DATABASE_URL: ${DATABASE_URL}
TENDERMINT_URL: ${TENDERMINT_URL}
CACHE_URL: ${CACHE_URL}
WEBSERVER_PORT: ${WEBSERVER_PORT}
environment: &env-vars
<<: *build-args
command: "./service \
--tendermint-url ${TENDERMINT_URL} \
--database-url ${DATABASE_URL}"
DATABASE_URL: ${DATABASE_URL:-postgres://postgres:${POSTGRES_PASSWORD:?}@postgres:5432/namada-indexer}
TENDERMINT_URL: ${TENDERMINT_URL}
CACHE_URL: ${CACHE_URL:-redis://dragonfly:6379}
command: |
./service
extra_hosts:
- "host.docker.internal:host-gateway"

include:
- docker-compose-db.yml
- "host.docker.internal:host-gateway"

services:
postgres:
image: postgres:16-alpine
command: [ "postgres", "-c", "max_connections=200" ]
expose:
- "5432"
environment:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?}
POSTGRES_DB: namada-indexer
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U postgres -d namada-indexer" ]
interval: 5s
timeout: 5s
retries: 5
restart: unless-stopped
volumes:
- type: volume
source: postgres-data
target: /var/lib/postgresql/data

dragonfly:
image: docker.dragonflydb.io/dragonflydb/dragonfly
command: --logtostderr --cache_mode=true --port 6379 -dbnum 1
ulimits:
memlock: -1
expose:
- "6379"
healthcheck:
test: [ "CMD-SHELL", "redis-cli ping | grep PONG" ]
interval: 5s
timeout: 5s
retries: 5
restart: unless-stopped

chain:
<<: *defaults
image: namada/chain-indexer
command: "./service \
--tendermint-url ${TENDERMINT_URL} \
--database-url ${DATABASE_URL} \
--initial-query-retry-time=15"
environment:
<<: *env-vars
INITIAL_QUERY_RETRY_TIME: ${INITIAL_QUERY_RETRY_TIME:-15}
build:
<<: *build
args:
<<: *build-args
PACKAGE: chain

governance:
Expand All @@ -44,7 +69,6 @@ services:
build:
<<: *build
args:
<<: *build-args
PACKAGE: governance

pos:
Expand All @@ -53,7 +77,6 @@ services:
build:
<<: *build
args:
<<: *build-args
PACKAGE: pos

rewards:
Expand All @@ -62,7 +85,6 @@ services:
build:
<<: *build
args:
<<: *build-args
PACKAGE: rewards

parameters:
Expand All @@ -71,7 +93,6 @@ services:
build:
<<: *build
args:
<<: *build-args
PACKAGE: parameters

transactions:
Expand All @@ -80,20 +101,19 @@ services:
build:
<<: *build
args:
<<: *build-args
PACKAGE: transactions

webserver:
<<: *defaults
image: namada/webserver-indexer
build:
context: .
dockerfile: Dockerfile
<<: *build
args:
PACKAGE: webserver
command: "./service"
expose:
- 5001
ports:
- ${WEBSERVER_PORT}:5001
- ${WEBSERVER_HOST_IP:-127.0.0.1}:${WEBSERVER_PORT:-5001}:5001
environment:
<<: *env-vars
healthcheck:
Expand All @@ -103,3 +123,5 @@ services:
retries: 5
restart: unless-stopped

volumes:
postgres-data:
26 changes: 0 additions & 26 deletions webserver/Dockerfile

This file was deleted.