mirror of
https://github.com/topjohnwu/magiskbot.git
synced 2024-11-26 21:30:47 +00:00
Migrate to fly.io
This commit is contained in:
parent
582962c517
commit
d1df07c92c
4
.dockerignore
Normal file
4
.dockerignore
Normal file
@ -0,0 +1,4 @@
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
node_modules
|
||||
.git
|
36
Dockerfile
Normal file
36
Dockerfile
Normal file
@ -0,0 +1,36 @@
|
||||
FROM debian:bullseye as builder
|
||||
|
||||
ARG NODE_VERSION=19.0.1
|
||||
|
||||
RUN apt-get update; apt install -y curl
|
||||
RUN curl https://get.volta.sh | bash
|
||||
ENV VOLTA_HOME /root/.volta
|
||||
ENV PATH /root/.volta/bin:$PATH
|
||||
RUN volta install node@${NODE_VERSION}
|
||||
|
||||
#######################################################################
|
||||
|
||||
RUN mkdir /app
|
||||
WORKDIR /app
|
||||
|
||||
# NPM will not install any package listed in "devDependencies" when NODE_ENV is set to "production",
|
||||
# to install all modules: "npm install --production=false".
|
||||
# Ref: https://docs.npmjs.com/cli/v9/commands/npm-install#description
|
||||
|
||||
ENV NODE_ENV production
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN npm install --production=false && npm run build
|
||||
FROM debian:bullseye
|
||||
|
||||
LABEL fly_launch_runtime="nodejs"
|
||||
|
||||
COPY --from=builder /root/.volta /root/.volta
|
||||
COPY --from=builder /app /app
|
||||
|
||||
WORKDIR /app
|
||||
ENV NODE_ENV production
|
||||
ENV PATH /root/.volta/bin:$PATH
|
||||
|
||||
CMD [ "npm", "run", "prod" ]
|
37
fly.toml
Normal file
37
fly.toml
Normal file
@ -0,0 +1,37 @@
|
||||
app = "magiskbot"
|
||||
kill_signal = "SIGINT"
|
||||
kill_timeout = 5
|
||||
processes = []
|
||||
|
||||
[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"
|
@ -4,7 +4,6 @@ import fetch from 'node-fetch';
|
||||
if (
|
||||
process.env.MAGISK_BOT_TOKEN === undefined ||
|
||||
process.env.MAGISK_OWNER_TOKEN === undefined ||
|
||||
process.env.MAGISK_BOT_DOMAIN === undefined ||
|
||||
process.env.MAGISK_WEBHOOK_SECRET === undefined ||
|
||||
process.env.PORT === undefined
|
||||
) {
|
||||
|
@ -7,11 +7,6 @@ async function main() {
|
||||
await blockAllSpam();
|
||||
setInterval(blockAllSpam, 8 * 60 * 60 * 1000);
|
||||
|
||||
// Wake Heroku every 15 mins
|
||||
setInterval(async () => {
|
||||
await fetch(`${process.env.MAGISK_BOT_DOMAIN}/ping`);
|
||||
}, 15 * 60 * 1000);
|
||||
|
||||
// Start webhook server
|
||||
try {
|
||||
await server.listen({ port: Number(process.env.PORT), host: '0.0.0.0' });
|
||||
|
Loading…
Reference in New Issue
Block a user