Skip to content

Commit

Permalink
added docker fly files
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasfr committed Dec 4, 2024
1 parent 95ea356 commit ca8d5bb
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 2 deletions.
77 changes: 77 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
node_modules
public/build
build
dist
out
coverage
.history
.react-router

# Other Coverage tools
*.lcov

# macOS
.DS_*
**/.DS_*

# Cache Directories and files
.cache
.yarn*
.env*
!.env.example
.swp*
.turbo
.npm
.stylelintcache
*.tsbuildinfo
.node_repl_history

# Lock files from other package managers
package-lock.json
yarn.lock

# General tempory files and directories
t?mp
.t?mp
*.t?mp

# Docusaurus cache and generated files
.docusaurus

# Output of 'npm pack'
*.tgz
*.tar
*.tar.gz
*.tar.bz2
*.tbz
*.zip

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
vite.config.ts.*

# Playwright various test reports
test-results
playwright-report
blob-report


# Editors
.idea/workspace.xml
.idea/usage.statistics.xml
.idea/shelf
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- run: pnpm install --prefer-offline --frozen-lockfile
# - run: pnpm run typecheck
- run: |
echo "Type check: ✅ (but disabled)"
echo "Type Checks are disabled"
vitest:
needs: typecheck
Expand Down
50 changes: 50 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# syntax = docker/dockerfile:1.4

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

# Node.js app lives here
WORKDIR /app

# Set production environment
ENV NODE_ENV="production"

# Install pnpm
ARG PNPM_VERSION=9.14.4
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 pkg-config python-is-python3 git jq openssl

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

# Copy application code
COPY . .

# Build application
RUN pnpm run build

RUN pnpm prisma generate

# Remove development dependencies
RUN pnpm prune --prod

# Final stage for app image
FROM base

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

ENV PORT="8080"
EXPOSE $PORT

# Start the server by default, this can be overwritten at runtime
CMD [ "pnpm", "run", "start" ]
36 changes: 36 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
primary_region = 'ams'
kill_signal = "SIGINT"
kill_timeout = 5

[env]
APP_DEPLOYMENT_ENV = "staging"

[deploy]
strategy = "rolling"

[[services]]
protocol = "tcp"
auto_stop_machines = "suspend"
auto_start_machines = true
min_machines_running = 0
processes = ['app']

[services.concurrency]
hard_limit = 100
soft_limit = 50
type = "requests"

[[services.ports]]
handlers = ["tls", "http"]
port = 443

[[services.tcp_checks]]
grace_period = "1s"
interval = "15s"
restart_limit = 0
timeout = "2s"

[[vm]]
size = "shared-cpu-1x"
memory = "512mb"
processes = ["app"]
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"script": "tsx scripts/setup.ts",
"cleanup": "pnpm run script scripts/cleanup.ts",
"build": "NODE_ENV=production react-router build",
"predev": "pnpm run typegen",
"dev": "react-router dev",
"db:pull": "prisma db pull",
"db:push": "prisma db push",
Expand All @@ -28,7 +29,6 @@
"check:unused": "knip --max-issues 1",
"check:unused:fix": "knip --fix",
"typegen": "react-router typegen",
"postinstall": "pnpm run typegen",
"generate-env": "pnpm run generate-env:good-os",
"generate-env:good-os": "APP_DEPLOYMENT_ENV=${APP_DEPLOYMENT_ENV:=development} op inject -i .env.example -o .env",
"generate-env:windows": "APP_DEPLOYMENT_ENV=development op inject -i .env.example -o .env"
Expand Down

0 comments on commit ca8d5bb

Please sign in to comment.