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

Move docker files around for consistency #322

Merged
merged 1 commit into from
Oct 29, 2024
Merged
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
4 changes: 4 additions & 0 deletions docker/full-project-docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This is for top-level docker compositions which run the entire NUTC stack
# Anything in dev should work for local development and uses emulators
# Note: local-dev/grafana-only will just run grafana, allowing you to run the exchange locally (quicker dev cycles)
# TODO: create sandbox-prod
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Used if you're running the exchange outside of docker (for quick dev cycles),
# but still want to use grafana/prometheus

services:
# Exposed on port 9000
prometheus:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
sandbox:
image: nutc-exchange
build:
context: ../..
context: ../../..
dockerfile: exchange/docker/sandbox/Dockerfile
args:
firebase_emulator: "false"
Expand All @@ -19,15 +19,15 @@ services:
webserver:
image: nutc-webserver
build:
context: ../..
context: ../../..
dockerfile: webserver/Dockerfile
restart: unless-stopped

linter:
image: nutc-linter
restart: unless-stopped
build:
context: ../..
context: ../../..
dockerfile: exchange/docker/linter/Dockerfile
args:
firebase_emulator: "false"
Expand All @@ -36,7 +36,7 @@ services:
prometheus:
image: prom/prometheus
volumes:
- ../../exchange/docker/sandbox/prometheus.yml:/etc/prometheus/prometheus.yml
- ./prometheus.yml:/etc/prometheus/prometheus.yml
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.retention.time=12h'
Expand Down Expand Up @@ -65,7 +65,7 @@ services:
- GF_AUTH_ANONYMOUS_ORG_NAME=MAIN
- GF_AUTH_ANONYMOUS_ORG_ROLE=Viewer
volumes:
- ../../exchange/docker/dev/grafana_data:/var/lib/grafana
- ./grafana_data:/var/lib/grafana
# - /var/lib/grafana/grafana.db
# - /var/lib/grafana/alerting

Expand Down
File renamed without changes.
51 changes: 0 additions & 51 deletions docker/prod/nginx.conf

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,57 +1,47 @@
# Full stack docker compose
# Remove web/firebase components for prod

version: '3'
services:
sandbox:
nutc-exchange1:
image: nutc-exchange
build:
context: ../../..
dockerfile: exchange/docker/sandbox/Dockerfile
restart: unless-stopped
environment:
- NUTC_EXPOSE_METRICS=1
- NUTC_ALGO_ENDPOINT=http://webserver:16124/algorithms/HFT
- NUTC_ID=0
depends_on:
- webserver
nutc-exchange2:
image: nutc-exchange
build:
context: ../..
context: ../../..
dockerfile: exchange/docker/sandbox/Dockerfile
args:
firebase_emulator: "false"
restart: unless-stopped
environment:
- NUTC_EXPOSE_METRICS=1
command: ["--sandbox"]
- NUTC_ALGO_ENDPOINT=http://webserver:16124/algorithms/HFT
- NUTC_ID=1
depends_on:
- webserver

#port: 16124
webserver:
image: nutc-webserver
build:
context: ../..
context: ../../..
dockerfile: webserver/Dockerfile
restart: unless-stopped

linter:
image: nutc-linter
restart: unless-stopped
build:
context: ../..
dockerfile: exchange/docker/linter/Dockerfile
args:
firebase_emulator: "false"

# Exposed on port 9000
prometheus:
image: prom/prometheus
volumes:
- ../../exchange/docker/sandbox/prometheus.yml:/etc/prometheus/prometheus.yml
- ./prometheus.yml:/etc/prometheus/prometheus.yml
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.retention.time=12h'
restart: unless-stopped

reverse-proxy:
image: nginx:latest
ports:
- "26389:80"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
restart: unless-stopped
depends_on:
- webserver
- grafana

grafana:
image: grafana/grafana
Expand All @@ -65,6 +55,4 @@ services:
- GF_AUTH_ANONYMOUS_ORG_NAME=MAIN
- GF_AUTH_ANONYMOUS_ORG_ROLE=Viewer
volumes:
- ../../exchange/docker/dev/grafana_data:/var/lib/grafana
# - /var/lib/grafana/grafana.db
# - /var/lib/grafana/alerting
- ./exchange/docker/dev/grafana_data:/var/lib/grafana
46 changes: 46 additions & 0 deletions docker/production/competition/grafana-only/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Used if you're running the exchange outside of docker (for quick dev cycles),
# but still want to use grafana/prometheus

services:
# Exposed on port 9000
prometheus:
image: prom/prometheus
ports:
- "9090:9090"

# allow prometheus to access exchange on the host
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.retention.time=12h'
networks:
- net

grafana:
image: grafana/grafana

# Ensure you have the following set in your .bashrc/.zshrc
#export UID=$(id -u)
#export GID=$(id -g)
user: "${UID}:${GID}"

ports:
- "3000:3000"
environment:
- GF_SECURITY_ALLOW_EMBEDDING=true
- GF_AUTH_ANONYMOUS_ENABLED=true
- GF_AUTH_ANONYMOUS_ORG_NAME=MAIN
- GF_AUTH_ANONYMOUS_ORG_ROLE=Viewer
volumes:
- ./grafana_data:/var/lib/grafana
networks:
- net

networks:
net:
ipam:
config:
- subnet: 172.20.0.0/16
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

{{ define "__subject" }}[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ if gt (.Alerts.Resolved | len) 0 }}, RESOLVED:{{ .Alerts.Resolved | len }}{{ end }}{{ end }}] {{ .GroupLabels.SortedPairs.Values | join " " }} {{ if gt (len .CommonLabels) (len .GroupLabels) }}({{ with .CommonLabels.Remove .GroupLabels.Names }}{{ .Values | join " " }}{{ end }}){{ end }}{{ end }}

{{ define "__text_values_list" }}{{ if len .Values }}{{ $first := true }}{{ range $refID, $value := .Values -}}
{{ if $first }}{{ $first = false }}{{ else }}, {{ end }}{{ $refID }}={{ $value }}{{ end -}}
{{ else }}[no value]{{ end }}{{ end }}

{{ define "__text_alert_list" }}{{ range . }}
Value: {{ template "__text_values_list" . }}
Labels:
{{ range .Labels.SortedPairs }} - {{ .Name }} = {{ .Value }}
{{ end }}Annotations:
{{ range .Annotations.SortedPairs }} - {{ .Name }} = {{ .Value }}
{{ end }}{{ if gt (len .GeneratorURL) 0 }}Source: {{ .GeneratorURL }}
{{ end }}{{ if gt (len .SilenceURL) 0 }}Silence: {{ .SilenceURL }}
{{ end }}{{ if gt (len .DashboardURL) 0 }}Dashboard: {{ .DashboardURL }}
{{ end }}{{ if gt (len .PanelURL) 0 }}Panel: {{ .PanelURL }}
{{ end }}{{ end }}{{ end }}

{{ define "default.title" }}{{ template "__subject" . }}{{ end }}

{{ define "default.message" }}{{ if gt (len .Alerts.Firing) 0 }}**Firing**
{{ template "__text_alert_list" .Alerts.Firing }}{{ if gt (len .Alerts.Resolved) 0 }}

{{ end }}{{ end }}{{ if gt (len .Alerts.Resolved) 0 }}**Resolved**
{{ template "__text_alert_list" .Alerts.Resolved }}{{ end }}{{ end }}


{{ define "__teams_text_alert_list" }}{{ range . }}
Value: {{ template "__text_values_list" . }}
Labels:
{{ range .Labels.SortedPairs }} - {{ .Name }} = {{ .Value }}
{{ end }}
Annotations:
{{ range .Annotations.SortedPairs }} - {{ .Name }} = {{ .Value }}
{{ end }}
{{ if gt (len .GeneratorURL) 0 }}Source: [{{ .GeneratorURL }}]({{ .GeneratorURL }})

{{ end }}{{ if gt (len .SilenceURL) 0 }}Silence: [{{ .SilenceURL }}]({{ .SilenceURL }})

{{ end }}{{ if gt (len .DashboardURL) 0 }}Dashboard: [{{ .DashboardURL }}]({{ .DashboardURL }})

{{ end }}{{ if gt (len .PanelURL) 0 }}Panel: [{{ .PanelURL }}]({{ .PanelURL }})

{{ end }}
{{ end }}{{ end }}


{{ define "teams.default.message" }}{{ if gt (len .Alerts.Firing) 0 }}**Firing**
{{ template "__teams_text_alert_list" .Alerts.Firing }}{{ if gt (len .Alerts.Resolved) 0 }}

{{ end }}{{ end }}{{ if gt (len .Alerts.Resolved) 0 }}**Resolved**
{{ template "__teams_text_alert_list" .Alerts.Resolved }}{{ end }}{{ end }}
Binary file not shown.
7 changes: 7 additions & 0 deletions docker/production/competition/grafana-only/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
global:
scrape_interval: 2s

scrape_configs:
- job_name: 'exchange-sandbox'
static_configs:
- targets: ['host.docker.internal:4152']
7 changes: 7 additions & 0 deletions docker/production/competition/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
global:
scrape_interval: 2s

scrape_configs:
- job_name: 'exchange-sandbox'
static_configs:
- targets: ['nutc-exchange1:4152', 'nutc-exchange2:4152']
Loading