Code changes to make it work with Fly.io

This commit is contained in:
JBB0807 2025-04-21 17:14:11 -07:00
parent 5b93901976
commit 0695a01f17
9 changed files with 100 additions and 85 deletions

View file

@ -5,8 +5,8 @@
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
#use this when testing local, remmber to run the proxy command
DATABASE_URL="postgresql://postgres:wly9H8gjjmxYfg1@localhost:15432/postgres?schema=public"
# DATABASE_URL="postgresql://postgres:wly9H8gjjmxYfg1@localhost:15432/postgres?schema=public"
# DATABASE_URL="postgres://postgres:w2eSd47GJEdqvMf@snakebyte.internal:5432"
DATABASE_URL="postgres://postgres:wly9H8gjjmxYfg1@bytecamp-db.flycast:5432?sslmode=disable"
# DATABASE_URL=postgres://snakebyte:zVB7lgOiKr89dq6@localhost:5432/snakebyte?sslmode=disable
NODE_PORT=3000

View file

@ -0,0 +1,20 @@
# syntax=docker/dockerfile:1
# Use the official Node.js image as the base image
ARG NODE_VERSION=22.13.1
FROM node:${NODE_VERSION}-slim AS base
# Set the working directory
WORKDIR /app
COPY . .
RUN apt-get update -y && apt-get install -y openssl && npm install && npx prisma generate
# Copy the application source code
COPY --link . .
# Expose the application port
EXPOSE 3000
# Define the command to run the application
CMD ["node", "app.js"]

View file

@ -1,69 +1,45 @@
# fly.toml app configuration file generated for snakebyte on 2025-01-04T01:06:05-08:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#
# fly.toml file for a Node.js service that connects to an external Postgres DB
app = 'db-user-service'
primary_region = 'sea'
app = "db-user-service"
primary_region = "sea"
[env]
PRIMARY_REGION = 'sea'
[build]
# Only needed if you're using a Dockerfile — can be empty if using buildpacks or Node preset
[[mounts]]
source = 'pg_data'
destination = '/data'
#[env]
#NODE_ENV = "production"
#DATABASE_URL = "postgresql://user:password@hostname:port/dbname"
# you can also leave DATABASE_URL unset here and use secrets instead
# Removed the [http_service] section to disable public HTTP/HTTPS access
# [http_service]
# internal_port = 3000
# force_https = true
# auto_stop_machines = true
# auto_start_machines = true
# min_machines_running = 0
# processes = ["app"]
[[services]]
protocol = 'tcp'
internal_port = 5432
auto_start_machines = false
protocol = "tcp"
internal_port = 3000
internal_only = true # Makes this service only accessible internally
[[services.ports]]
port = 5432
handlers = ['pg_tls']
# Removed public port exposure
# [[services.ports]]
# port = 80
# handlers = ["http"]
# [[services.ports]]
# port = 443
# handlers = ["tls", "http"]
[services.concurrency]
type = 'connections'
type = "requests"
hard_limit = 1000
soft_limit = 1000
soft_limit = 500
[[services]]
protocol = 'tcp'
internal_port = 5433
auto_start_machines = false
[[services.ports]]
port = 5433
handlers = ['pg_tls']
[services.concurrency]
type = 'connections'
hard_limit = 1000
soft_limit = 1000
[checks]
[checks.pg]
port = 5500
type = 'http'
interval = '15s'
timeout = '10s'
path = '/flycheck/pg'
[checks.role]
port = 5500
type = 'http'
interval = '15s'
timeout = '10s'
path = '/flycheck/role'
[checks.vm]
port = 5500
type = 'http'
interval = '15s'
timeout = '10s'
path = '/flycheck/vm'
[[metrics]]
port = 9187
path = '/metrics'
https = false
[[vm]]
memory = "512mb"
cpu_kind = "shared"
cpus = 1