infra-role-geth/templates/docker-compose.yml.j2

104 lines
3.1 KiB
Django/Jinja

---
version: '3.7'
services:
geth:
container_name: '{{ geth_cont_name }}'
image: '{{ geth_cont_image }}'
user: root
restart: 'always'
stop_grace_period: '{{ geth_cont_stop_grace_period }}'
deploy:
resources:
limits:
memory: '{{ geth_cont_mem_limit }}m'
ports:
- '{{ geth_port }}:{{ geth_port }}/tcp'
- '{{ geth_port }}:{{ geth_port }}/udp'
{% if geth_metrics_enabled %}
- '{{ geth_metrics_port }}:{{ geth_metrics_port }}/tcp'
{% endif %}
{% if geth_websocket_enabled %}
- '{{ geth_websocket_addr }}:{{ geth_websocket_port }}:{{ geth_websocket_port }}/tcp'
{% endif %}
{% if geth_rpc_enabled %}
- '{{ geth_rpc_addr }}:{{ geth_rpc_port }}:{{ geth_rpc_port }}/tcp'
{% endif %}
{% if geth_authrpc_enabled %}
- '{{ geth_authrpc_addr }}:{{ geth_authrpc_port }}:{{ geth_authrpc_port }}/tcp'
{% endif %}
labels:
# These are just for documentation
org.ethereum.geth.network_name: '{{ geth_network_name }}'
volumes:
- '{{ geth_cont_vol }}/keys:/keys:rw'
- '{{ geth_cont_vol }}/data:/data:rw'
command: |
{% if geth_network_id is defined %}
--networkid={{ geth_network_id }}
{% elif geth_network_name != "mainnet" %}
--{{ geth_network_name }}
{% endif %}
{% if not geth_discovery_enabled %}
--nodiscover
{% endif %}
{% if geth_v5disc_enabled %}
--v5disc
{% endif %}
--syncmode={{ geth_sync_mode }}
{% if geth_sync_mode != 'light' %}
--light.serve={{ geth_light_serv }}
{% endif %}
{% if geth_miner_enabled %}
--mine
--miner.etherbase="{{ geth_miner_account | mandatory }}"
{% endif %}
{% if geth_whisper_enabled %}
--shh
--shh.pow={{ geth_whisper_pow }}
{% endif %}
{% if geth_metrics_enabled %}
--metrics
--metrics.addr=0.0.0.0
--metrics.port={{ geth_metrics_port }}
{% endif %}
{% if geth_cache_size %}
--cache={{ geth_cache_size }}
{% endif %}
{% if geth_rpc_enabled %}
--http
--http.addr=0.0.0.0
--http.port={{ geth_rpc_port }}
--http.vhosts={{ geth_rpc_vhosts | sort | join(",") }}
--http.api={{ geth_rcp_api }}
--ipcpath=/data/geth.ipc
{% endif %}
{% if geth_websocket_enabled %}
--ws
--ws.addr=0.0.0.0
--ws.port={{ geth_websocket_port }}
--ws.api={{ geth_websocket_api }}
--ws.origins={{ geth_websocket_origins | sort | join(",") }}
{% endif %}
{% if geth_authrpc_enabled %}
--authrpc.addr=0.0.0.0
--authrpc.port={{ geth_authrpc_port }}
--authrpc.vhosts={{ geth_authrpc_vhosts | sort | join(",") }}
--authrpc.jwtsecret=/keys/jwtsecret
{% endif %}
{% if (geth_bootnodes|length) > 0 %}
--bootnodes="{{ geth_bootnodes | sort | join(',') }}"
{% endif %}
--verbosity={{ geth_log_level_id }}
--maxpeers={{ geth_max_peers }}
--maxpendpeers="{{ geth_max_pend_peers }}"
--port={{ geth_port }}
--nat=extip:{{ geth_public_addr }}
--unlock={{ geth_account_addr }}
--allow-insecure-unlock
--datadir=/data
--password=/keys/account.pass
--keystore=/keys
{% for extra_flag in geth_extra_flags %}
{{ extra_flag }}
{% endfor %}