Fly.io setup with 1 machine

This commit is contained in:
Dominic Ferrando
2025-05-04 15:23:05 -04:00
parent d5da472661
commit 228b4a7b94
6 changed files with 90 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
fly.toml
Dockerfile
.dockerignore
node_modules
.git
+18
View File
@@ -0,0 +1,18 @@
# See https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/
name: Fly Deploy
on:
push:
branches:
- main
jobs:
deploy:
name: Deploy app
runs-on: ubuntu-latest
concurrency: deploy-group # optional: ensure only one action runs at a time
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
+35
View File
@@ -0,0 +1,35 @@
# syntax = docker/dockerfile:1
FROM oven/bun:1.2.12-slim as base
LABEL fly_launch_runtime="Bun"
# NodeJS app lives here
WORKDIR /app
# Set production environment
ENV NODE_ENV=production
# Throw-away build stage to reduce size of final image
FROM base as build
# Install packages needed to build node modules
RUN apt-get update -qq && \
apt-get install -y python-is-python3 pkg-config build-essential
# Install node modules
COPY --link package.json .
RUN bun install --production
# Copy application code
COPY --link . .
# Final stage for app image
FROM base
# Copy built application
COPY --from=build /app /app
# Start the server by default, this can be overwritten at runtime
CMD [ "bun", "run", "start" ]
+25
View File
@@ -0,0 +1,25 @@
# fly.toml app configuration file generated for blade-and-brawn on 2025-05-04T14:56:24-04:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#
app = 'blade-and-brawn'
primary_region = 'ord'
[build]
[env]
PORT = '8080'
[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = 'stop'
auto_start_machines = true
min_machines_running = 0
processes = ['app']
[[vm]]
memory = '1gb'
cpu_kind = 'shared'
cpus = 1
+5
View File
@@ -6,6 +6,11 @@ const productRecords = new ProductRecords();
const server = Bun.serve({
routes: {
"/test": {
async GET(req){
return Response.json("Hello world");
}
},
"/webhook/printful": {
async POST(req) {
const payload: Printful.Webhook.EventPayload = await req.json()
+2 -1
View File
@@ -4,6 +4,7 @@
"@types/bun": "^1.2.11"
},
"scripts": {
"db:seed": "sqlite3 ./database/data.db < ./database/seed.sql"
"db:seed": "sqlite3 ./database/data.db < ./database/seed.sql",
"start": "bun run main.ts"
}
}