fli.io files & create, configure, deploy actions

This commit is contained in:
Smith
2023-02-24 19:00:35 +01:00
parent 677412bfe7
commit 46b95cfca8
8 changed files with 167 additions and 11 deletions

16
.dockerignore Normal file
View File

@@ -0,0 +1,16 @@
fly.toml
Dockerfile
.dockerignore
node_modules
.git
*.tsbuildinfo
app.json
azuredeploy.json
Procfile
.nvmrc
.env.example
.env
.do
.github
.vscode
data/*.json

38
.github/workflows/configure.yml vendored Normal file
View File

@@ -0,0 +1,38 @@
name: ⚙ Configure cloud app
on:
workflow_dispatch:
inputs:
secret:
description: 'Admin secret'
type: string
default: ''
required: true
discord_bot_token:
description: 'Discord bot token'
type: string
default: ''
telegram_bot_token:
description: 'Telegram bot token'
type: string
default: ''
steam_web_api_key:
description: 'Steam web API key'
type: string
default: ''
jobs:
configure:
name: 🛬 Create/update the secrets and env vars
runs-on: ubuntu-latest
steps:
- uses: superfly/flyctl-actions/setup-flyctl@master
- name: 🛩 Update on fly.io
run: |
flyctl secrets set SECRET=${{ secrets.SECRET }} --app ${{ github.repository_owner }}-gsw
flyctl secrets set DISCORD_BOT_TOKEN=${{ secrets.DISCORD_BOT_TOKEN }} --app ${{ github.repository_owner }}-gsw
flyctl secrets set TELEGRAM_BOT_TOKEN=${{ secrets.TELEGRAM_BOT_TOKEN }} --app ${{ github.repository_owner }}-gsw
flyctl secrets set STEAM_WEB_API_KEY=${{ secrets.STEAM_WEB_API_KEY }} --app ${{ github.repository_owner }}-gsw
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

18
.github/workflows/create.yml vendored Normal file
View File

@@ -0,0 +1,18 @@
name: 🏗 Create cloud app
on:
workflow_dispatch:
jobs:
create:
name: 🛫 Create the app and volume entries
runs-on: ubuntu-latest
steps:
- uses: superfly/flyctl-actions/setup-flyctl@master
- name: 🛩 Create on fly.io
run: |
flyctl apps create ${{ github.repository_owner }}-gsw
flyctl volumes create gsw_data --region ${{ secrets.FLY_REGION }} --size 1
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

View File

@@ -2,20 +2,23 @@ name: ☁️ Deploy to the cloud
on:
workflow_dispatch:
# push:
# branches:
# - master
push:
branches:
- master
jobs:
push:
deploy:
name: 🚀 Deploy app
runs-on: ubuntu-latest
steps:
- name: 🚚 Get latest code
uses: actions/checkout@v2
- uses: actions/checkout@v3
name: 🚚 Get latest code
with:
fetch-depth: 0
- name: 🐙 Add new remote, and push to master
run: |
git remote add cloudrepo ${{ secrets.CLOUD_REPO_URL }}
git push -f cloudrepo ${{ github.ref_name }}:master
- uses: superfly/flyctl-actions/setup-flyctl@master
- name: 🛩 Deploy to fly.io
run: flyctl deploy --remote-only --auto-confirm --region ${{ secrets.FLY_REGION }} --app ${{ github.repository_owner }}-gsw --env
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

1
.gitignore vendored
View File

@@ -5,6 +5,7 @@ logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.vscode
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

2
.nvmrc
View File

@@ -1 +1 @@
12.20.1
16.15.1

34
Dockerfile Normal file
View File

@@ -0,0 +1,34 @@
FROM debian:bullseye as builder
ARG NODE_VERSION=16.15.1
RUN apt-get update; apt install -y curl python-is-python3 pkg-config build-essential
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
COPY . .
RUN npm install --production=false && npm run build
RUN rm -rf node_modules && npm install --production=true
#######################################################################
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", "start" ]

46
fly.toml Normal file
View File

@@ -0,0 +1,46 @@
app = "game-server-watcher"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []
[env]
DBG=0
REFRESH_TIME_MINUTES=2
DATA_PATH = /data/
[mounts]
source="gsw_data"
destination="/data"
[experimental]
auto_rollback = true
allowed_public_ports = []
# cmd = ["node", "--max-old-space-size=180", "server.js"]
[[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"