Skip to content

Commit

Permalink
Setup for prod
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenewald committed Oct 7, 2024
1 parent 11b69ab commit 3130fcb
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 15 deletions.
70 changes: 70 additions & 0 deletions docker/prod/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Full stack docker compose
# Remove web/firebase components for prod

version: '3'
services:
sandbox:
image: nutc-exchange
build:
context: ../..
dockerfile: exchange/docker/sandbox/Dockerfile
args:
firebase_emulator: "false"
restart: unless-stopped
environment:
- NUTC_EXPOSE_METRICS=1
command: ["--sandbox"]

#port: 16124
webserver:
image: nutc-webserver
build:
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
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
restart: unless-stopped
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:
- ../../exchange/docker/dev/grafana_data:/var/lib/grafana
# - /var/lib/grafana/grafana.db
# - /var/lib/grafana/alerting
51 changes: 51 additions & 0 deletions docker/prod/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
user nginx;
worker_processes 1;

events {
worker_connections 1024;
}


http {
sendfile on;
keepalive_timeout 65;

map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}

upstream webserver {
server webserver:16124;
}

upstream grafana {
server grafana:3000;
}

server {
listen 80;

location /webserver/ {
rewrite ^/webserver(/.*)$ $1 break;
proxy_pass http://webserver;
proxy_set_header Host $host;
# proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection "upgrade";
}

location / {
proxy_pass http://grafana;
proxy_set_header Host $host;
}

location /api/live/ {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_pass http://grafana;
}
}
}
11 changes: 4 additions & 7 deletions exchange/docker/linter/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,14 @@ RUN cmake --preset=ci-docker

RUN cmake --build build --config Release -j

RUN mv /app/exchange/build/LINTER_spawner /app/LINTER_spawner
RUN mv /app/exchange/build/LINTER /app/LINTER
ENV NUTC_LINTER_SPAWNER_BINARY_PATH="/app/exchange/build/LINTER_spawner"

ENV NUTC_LINTER_SPAWNER_BINARY_PATH="/app/LINTER_spawner"

RUN chmod +x /app/LINTER
RUN chmod +x /app/LINTER_spawner
RUN chmod +x /app/exchange/build/LINTER
RUN chmod +x /app/exchange/build/LINTER_spawner

COPY ./exchange/template.cpp /app/template.cpp
ENV NUTC_CPP_TEMPLATE_PATH="/app/template.cpp"

EXPOSE 18081

CMD /app/LINTER
CMD /app/exchange/build/LINTER
9 changes: 3 additions & 6 deletions exchange/docker/sandbox/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,17 @@ RUN cmake --preset=ci-docker

RUN cmake --build build --config Release -j

RUN mv /app/exchange/build/NUTC /app/NUTC
RUN mv /app/exchange/build/WRAPPER /app/WRAPPER

# Todo: make default?
COPY ./exchange/config.yml /app/exchange/config.yml

RUN chmod +x /app/NUTC /app/WRAPPER
RUN chmod +x /app/exchange/build/NUTC /app/exchange/build/WRAPPER

COPY ./exchange/template.cpp /app/template.cpp

ENV NUTC_WRAPPER_BINARY_PATH="/app/WRAPPER"
ENV NUTC_WRAPPER_BINARY_PATH="/app/exchange/build/WRAPPER"
ENV NUTC_CONFIG_FILE="/app/exchange/config.yml"
ENV NUTC_CPP_TEMPLATE_PATH="/app/template.cpp"

EXPOSE 4152 18080

ENTRYPOINT ["/app/NUTC"]
ENTRYPOINT ["/app/exchange/build/NUTC"]
2 changes: 0 additions & 2 deletions web/app/dash/submit/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ export default function SubmissionForm(props: { user: any }) {
});

const onSubmit: SubmitHandler<Inputs> = async data => {
Swal.fire({ title: "Submissions not yet open", text: "Check back morning of October 7th" });
return;
const responsePromise = fetch("/api/protected/db/user/createAlgo", {
method: "POST",
body: JSON.stringify(data),
Expand Down

0 comments on commit 3130fcb

Please sign in to comment.