From cdeca6bd8faacde3e7ea976bb816f07a07e64816 Mon Sep 17 00:00:00 2001 From: tfkhdyt Date: Tue, 26 Sep 2023 17:47:35 +0700 Subject: [PATCH] build: add Dockerfile --- .gitignore | 1 + Dockerfile | 24 ++++++++++++++++++++++++ fly.toml | 36 +++++------------------------------- 3 files changed, 30 insertions(+), 31 deletions(-) create mode 100644 Dockerfile diff --git a/.gitignore b/.gitignore index 9c97bbd..8ec76ca 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules dist .env +.env.production diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1e2add6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM oven/bun AS builder + +WORKDIR /src + +COPY . . + +ENV NODE_ENV=production + +RUN bun i && \ + bun run generate && \ + bun build --target bun --outfile dist/kbbi.js ./src/main.ts + +FROM oven/bun + +WORKDIR /app + +COPY --from=builder /src/dist/kbbi.js /app/kbbi.js +COPY --from=builder /src/package.json /app/package.json +COPY --from=builder /src/bun.lockb /app/bun.lockb +COPY --from=builder /src/drizzle /app/drizzle + +RUN bun i + +ENTRYPOINT [ "bun run /app/kbbi.js" ] diff --git a/fly.toml b/fly.toml index 2cf898d..4d26884 100644 --- a/fly.toml +++ b/fly.toml @@ -4,40 +4,14 @@ # app = "kbbi-bot-v2" -kill_signal = "SIGINT" -kill_timeout = "5s" +primary_region = "sin" [build] -builder = "heroku/buildpacks:20" -[env] -NODE_ENV = "production" -PORT = "8080" - -[experimental] -auto_rollback = true -cmd = ["node ./dist/app.js"] - -[[services]] +[http_service] internal_port = 8080 +force_https = true +auto_stop_machines = true +auto_start_machines = true min_machines_running = 0 processes = ["app"] -protocol = "tcp" -[services.concurrency] -hard_limit = 25 -soft_limit = 20 -type = "connections" - -[[services.ports]] -handlers = ["http"] -port = 80 - -[[services.ports]] -handlers = ["tls", "http"] -port = 443 - -[[services.tcp_checks]] -grace_period = "1s" -interval = "15s" -restart_limit = 0 -timeout = "2s"