Skip to content

Commit

Permalink
fly.io
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspermayone committed Oct 29, 2024
1 parent 3238073 commit 31e1916
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 82 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/fly-deploy.yml
Original file line number Diff line number Diff line change
@@ -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 }}
Empty file removed .husky/pre-commit
Empty file.
59 changes: 59 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# syntax = docker/dockerfile:1

# Adjust NODE_VERSION as desired
ARG NODE_VERSION=22.9.0
FROM node:${NODE_VERSION}-slim as base

LABEL fly_launch_runtime="Node.js/Prisma"

# Node.js/Prisma app lives here
WORKDIR /app

# Set production environment
ENV NODE_ENV="production"

# Install pnpm
ARG PNPM_VERSION=9.11.0
RUN npm install -g pnpm@$PNPM_VERSION


# 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 --no-install-recommends -y build-essential node-gyp openssl pkg-config python-is-python3

# Install node modules
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile --prod=false

# Generate Prisma Client
COPY prisma .
RUN npx prisma generate

# Copy application code
COPY . .

# Build application
RUN pnpm run build

# Remove development dependencies
RUN pnpm prune --prod


# Final stage for app image
FROM base

# Install packages needed for deployment
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y chromium chromium-sandbox openssl && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Copy built application
COPY --from=build /app /app

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
ENV PUPPETEER_EXECUTABLE_PATH="/usr/bin/chromium"
CMD [ "pnpm", "run", "start" ]
27 changes: 0 additions & 27 deletions Dockerfile.dev

This file was deleted.

32 changes: 0 additions & 32 deletions Dockerfile.prod

This file was deleted.

27 changes: 27 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# fly.toml app configuration file generated for phishdirectory-api on 2024-10-29T00:30:08-04:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'phishdirectory-api'
primary_region = 'yul'
kill_signal = 'SIGINT'
kill_timeout = '5s'

[build]

[deploy]
release_command = 'npx prisma migrate dev'

[http_service]
internal_port = 3000
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
15 changes: 2 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,13 @@
"url": "https://jaspermayone.com"
}
],
"packageManager": "[email protected]",
"scripts": {
"preinstall": "npx only-allow pnpm",
"start": "node dist/index.js",
"postinstall": "npx prisma generate && tsc",
"watch-node": "nodemon dist/index.js",
"watch-ts": "tsc -w",
"dev": "nodemon --quiet --watch './**/*.ts' --exec 'ts-node' src/index.ts",
"build": "npx prisma generate && tsc",
"compile": "npx prisma generate && tsc",
"heroku-prebuild": "echo This runs before Heroku installs dependencies.",
"heroku-postbuild": "echo This runs after Heroku installs dependencies, but before Heroku prunes and caches dependencies.",
"heroku-cleanup": "echo This runs after Heroku prunes and caches dependencies.",
"prepare": "husky",
"prisma:docker": "npx prisma generate && npx prisma migrate dev",
"dev:docker": "pnpm prisma:docker && pnpm dev"
"compile": "npx prisma generate && tsc"
},
"keywords": [],
"author": "Jasper Mayone <[email protected]>",
Expand Down Expand Up @@ -56,14 +47,12 @@
"@types/node-statsd": "^0.1.6",
"@types/request-ip": "^0.0.41",
"@types/response-time": "^2.3.8",
"husky": "^9.1.4",
"nodemon": "^3.1.4",
"prisma": "^5.18.0",
"typescript": "^5.5.4"
},
"engines": {
"node": "22.x",
"npm": "10.8.2",
"pnpm": "9.5.0"
"npm": "10.8.2"
}
}
10 changes: 0 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 31e1916

Please sign in to comment.