Skip to content

Commit

Permalink
ci: restore deployments to flyio
Browse files Browse the repository at this point in the history
  • Loading branch information
George-Spanos committed Mar 7, 2024
1 parent d50a446 commit a07a759
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 27 deletions.
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ services:
context: src/calc-odds-api
secrets:
- npmrc
env_file:
- src/calc-odds-api/.env
environment:
- ITERATIONS=50000
ports:
- 7071:7071
depends_on:
Expand All @@ -71,4 +71,4 @@ volumes:
external: true
secrets:
npmrc:
file: .npmrc
file: .npmrc
3 changes: 3 additions & 0 deletions src/calc-odds-api/deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 16 additions & 12 deletions src/calc-odds-api/fly.toml
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
# fly.toml app configuration file generated for ppo-calc-odds on 2023-12-31T19:49:23+02:00
# fly.toml app configuration file generated for ppo-calc-odds on 2024-03-07T00:49:22+02:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = "ppo-calc-odds"
primary_region = "ams"
app = 'ppo-calc-odds'
primary_region = 'ams'

[build]
dockerfile = "Dockerfile"
dockerfile = 'Dockerfile'

[http_service]
internal_port = 7071
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ["app"]
[[services.http_checks]]
grace_period = 10
interval = 30
timeout = 5
path = "/liveness"
processes = ['app']

[env]
ITERATIONS = "50000"

[[http_service.checks]]
grace_period = "10s"
interval = "30s"
method = "GET"
timeout = "5s"
path = "/liveness"

[[vm]]
cpu_kind = "shared"
memory = '512mb'
cpu_kind = 'shared'
cpus = 1
memory_mb = 1024
13 changes: 9 additions & 4 deletions src/calc-odds-api/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { calculateOdds } from "@poker-core/calculate-odds/calculate-odds.ts";
import { validateRound, Round } from "@poker-core/round/round.ts";
import { Application, Context, Next, Router } from "https://deno.land/x/oak@v14.0.0/mod.ts";

const port = Number(Deno.env.get('PORT') || '7071');

let iterations = Number(Deno.env.get('ITERATIONS'));
Expand All @@ -13,19 +14,23 @@ if (!iterations || iterations <= 0) {
const apiKey = Deno.env.get('APIKEY');

const router = new Router();
router.post('/api/calcOdds', async (ctx) => {
const body: { estimate: number, round: Round; } = await ctx.request.body.json();
router.post('/api/calcOdds', validateClient, async (ctx) => {
let body: { estimate: number, round: Round; };
try {
body = await ctx.request.body.json();
} catch {
return ctx.throw(400, 'failed to parse body');
}
if (!validateRound(body.round)) {
return ctx.throw(400, 'invalid round payload');
}
const odds = calculateOdds(body.round, iterations);
ctx.response.body = { odds };
});
router.get('/api/liveness', (ctx) => {
router.get('/liveness', (ctx) => {
ctx.response.body = 'Liveness Check Passed';
});
const app = new Application();
app.use(validateClient);
app.use(router.routes());
app.use(router.allowedMethods());

Expand Down
10 changes: 6 additions & 4 deletions src/ui/fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ primary_region = "ams"
auto_start_machines = true
min_machines_running = 0
processes = ["app"]
[[services.http_checks]]
grace_period = 10
interval = 30
timeout = 5

[[http_service.checks]]
grace_period = "10s"
interval = "30s"
timeout = "5s"
path = "/"

[[vm]]
cpu_kind = "shared"
cpus = 1
Expand Down
16 changes: 12 additions & 4 deletions src/web-api/fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,21 @@ auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ["app"]
[[services.http_checks]]
grace_period = 10
interval = 30
timeout = 5

[[services.ports]]
handlers = ["http"]
port = 80
force_https = true #

[[http_service.checks]]
grace_period = '10s'
interval = '30s'
timeout = '5s'
path = "/health/liveness"

[env]
LEADERBOARD_MIN_GAMES = "2"

[[vm]]
cpu_kind = "shared"
cpus = 1
Expand Down

0 comments on commit a07a759

Please sign in to comment.