Fly API deployment
This commit is contained in:
parent
ce9e5ab4c7
commit
c6e522f685
|
@ -0,0 +1,4 @@
|
||||||
|
*
|
||||||
|
!ISIN.db
|
||||||
|
!main.ts
|
||||||
|
!deps.ts
|
|
@ -0,0 +1,15 @@
|
||||||
|
name: API Deploy
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
push:
|
||||||
|
env:
|
||||||
|
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
name: Deploy app
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: superfly/flyctl-actions/setup-flyctl@master
|
||||||
|
- run: make db && flyctl deploy --remote-only
|
|
@ -1,7 +1,6 @@
|
||||||
name: Update Data
|
name: Update Data
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
push:
|
|
||||||
schedule:
|
schedule:
|
||||||
# 18:07 UTC every day
|
# 18:07 UTC every day
|
||||||
# 23:37 IST every day
|
# 23:37 IST every day
|
||||||
|
|
|
@ -3,3 +3,6 @@ release.md
|
||||||
pup.zip
|
pup.zip
|
||||||
IN*.csv
|
IN*.csv
|
||||||
notes.md
|
notes.md
|
||||||
|
ISIN.db
|
||||||
|
ISIN.sqbpro
|
||||||
|
scratchpad.txt
|
|
@ -0,0 +1,19 @@
|
||||||
|
FROM denoland/deno:1.22.0
|
||||||
|
|
||||||
|
# The port that your application listens to.
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Prefer not to run as root.
|
||||||
|
USER deno
|
||||||
|
|
||||||
|
# Cache the dependencies as a layer (the following two steps are re-run only when deps.ts is modified).
|
||||||
|
# Ideally cache deps.ts will download and compile _all_ external files used in main.ts.
|
||||||
|
COPY deps.ts .
|
||||||
|
RUN deno cache deps.ts
|
||||||
|
|
||||||
|
# These steps will be re-run upon each file change in your working directory:
|
||||||
|
ADD . .
|
||||||
|
|
||||||
|
CMD ["run", "--cached-only", "--allow-net", "--allow-read", "main.ts"]
|
9
Makefile
9
Makefile
|
@ -33,5 +33,10 @@ old:
|
||||||
release-notes: old
|
release-notes: old
|
||||||
python3 src/diff.py
|
python3 src/diff.py
|
||||||
|
|
||||||
release: release-notes
|
release: release-notes db
|
||||||
gh release create "$(version)" --notes-file notes.md ISIN.csv release.md
|
gh release create "$(version)" --notes-file notes.md ISIN.csv release.md ISIN.db
|
||||||
|
|
||||||
|
db:
|
||||||
|
cat ISIN.csv | tail -n +2 > /tmp/ISIN-no-headers.csv
|
||||||
|
rm -f ISIN.db
|
||||||
|
cat src/setup.sql | sqlite3 ISIN.db
|
|
@ -0,0 +1,8 @@
|
||||||
|
import { DB } from "https://deno.land/x/sqlite/mod.ts";
|
||||||
|
import {
|
||||||
|
app,
|
||||||
|
get,
|
||||||
|
post,
|
||||||
|
redirect,
|
||||||
|
contentType,
|
||||||
|
} from "https://denopkg.com/syumai/dinatra@0.15.0/mod.ts";
|
|
@ -0,0 +1,39 @@
|
||||||
|
app = "isin"
|
||||||
|
|
||||||
|
kill_signal = "SIGINT"
|
||||||
|
kill_timeout = 5
|
||||||
|
|
||||||
|
[env]
|
||||||
|
PORT = "8080"
|
||||||
|
|
||||||
|
[experimental]
|
||||||
|
allowed_public_ports = []
|
||||||
|
auto_rollback = true
|
||||||
|
|
||||||
|
|
||||||
|
[[services]]
|
||||||
|
http_checks = []
|
||||||
|
internal_port = 8080
|
||||||
|
processes = ["app"]
|
||||||
|
protocol = "tcp"
|
||||||
|
script_checks = []
|
||||||
|
|
||||||
|
[services.concurrency]
|
||||||
|
hard_limit = 25
|
||||||
|
soft_limit = 20
|
||||||
|
type = "connections"
|
||||||
|
|
||||||
|
[[services.ports]]
|
||||||
|
force_https = true
|
||||||
|
handlers = ["http"]
|
||||||
|
port = 80
|
||||||
|
|
||||||
|
[[services.ports]]
|
||||||
|
handlers = ["tls", "http"]
|
||||||
|
port = 443
|
||||||
|
|
||||||
|
[[services.tcp_checks]]
|
||||||
|
grace_period = "1s"
|
||||||
|
interval = "15s"
|
||||||
|
restart_limit = 0
|
||||||
|
timeout = "2s"
|
|
@ -0,0 +1,27 @@
|
||||||
|
import { DB } from "https://deno.land/x/sqlite/mod.ts";
|
||||||
|
import {
|
||||||
|
app,
|
||||||
|
get,
|
||||||
|
post,
|
||||||
|
redirect,
|
||||||
|
contentType,
|
||||||
|
} from "https://denopkg.com/syumai/dinatra@0.15.0/mod.ts";
|
||||||
|
|
||||||
|
const db = new DB("ISIN.db", { mode: "read" });
|
||||||
|
|
||||||
|
app(
|
||||||
|
get("/api/:isin", ({ params }) => {
|
||||||
|
let query = `SELECT * from ISIN WHERE ISIN='${params.isin}'`
|
||||||
|
let res = db.query(query);
|
||||||
|
|
||||||
|
if (res.length == 1) {
|
||||||
|
let [isin,description,issuer,type,status] = res[0]
|
||||||
|
if (issuer == "null") {
|
||||||
|
issuer = null
|
||||||
|
}
|
||||||
|
return [200, contentType("json"), JSON.stringify({ isin,description,issuer,type,status })]
|
||||||
|
} else {
|
||||||
|
return[404, contentType("json"), "Invalid ISIN"]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
|
@ -0,0 +1,5 @@
|
||||||
|
CREATE TABLE IF NOT EXISTS "ISIN"("ISIN" TEXT, "Description" TEXT, "Issuer" TEXT, "Type" TEXT COLLATE NOCASE, "Status" TEXT COLLATE NOCASE);
|
||||||
|
CREATE UNIQUE INDEX isinidx on ISIN (ISIN);
|
||||||
|
CREATE INDEX statusidx on ISIN (Status);
|
||||||
|
CREATE INDEX typeidx on ISIN (Type);
|
||||||
|
.import /tmp/ISIN-no-headers.csv ISIN --csv
|
Loading…
Reference in New Issue