Skip to content

Commit cf5f29a

Browse files
chore: deploy to fly
1 parent 13176a8 commit cf5f29a

7 files changed

Lines changed: 801 additions & 4 deletions

File tree

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/.git
2+
/node_modules
3+
.dockerignore
4+
.env
5+
Dockerfile
6+
fly.toml

.github/workflows/fly-deploy.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# See https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/
2+
3+
name: Fly Deploy
4+
on:
5+
push:
6+
branches:
7+
- main
8+
jobs:
9+
deploy:
10+
name: Deploy app
11+
runs-on: ubuntu-latest
12+
concurrency: deploy-group # optional: ensure only one action runs at a time
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: superfly/flyctl-actions/setup-flyctl@master
16+
- run: flyctl deploy --remote-only
17+
env:
18+
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

Dockerfile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# syntax = docker/dockerfile:1
2+
3+
# Adjust NODE_VERSION as desired
4+
ARG NODE_VERSION=20.12.1
5+
FROM node:${NODE_VERSION}-slim AS base
6+
7+
LABEL fly_launch_runtime="Next.js"
8+
9+
# Next.js app lives here
10+
WORKDIR /app
11+
12+
# Set production environment
13+
ENV NODE_ENV="production"
14+
15+
16+
# Throw-away build stage to reduce size of final image
17+
FROM base AS build
18+
19+
# Install packages needed to build node modules
20+
RUN apt-get update -qq && \
21+
apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3
22+
23+
# Install node modules
24+
COPY package-lock.json package.json ./
25+
RUN npm ci --include=dev
26+
27+
# Copy application code
28+
COPY . .
29+
30+
# Build application
31+
RUN npx next build --experimental-build-mode compile
32+
33+
# Remove development dependencies
34+
RUN npm prune --omit=dev
35+
36+
37+
# Final stage for app image
38+
FROM base
39+
40+
# Copy built application
41+
COPY --from=build /app /app
42+
43+
# Entrypoint sets up the container.
44+
ENTRYPOINT [ "/app/docker-entrypoint.js" ]
45+
46+
# Start the server by default, this can be overwritten at runtime
47+
EXPOSE 3000
48+
CMD [ "npm", "run", "start" ]

docker-entrypoint.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env node
2+
3+
const { spawn } = require('node:child_process')
4+
5+
const env = { ...process.env }
6+
7+
;(async() => {
8+
// launch application directly (build is already done in Dockerfile)
9+
await exec(process.argv.slice(2).join(' '))
10+
})()
11+
12+
function exec(command) {
13+
const child = spawn(command, { shell: true, stdio: 'inherit', env })
14+
return new Promise((resolve, reject) => {
15+
child.on('exit', code => {
16+
if (code === 0) {
17+
resolve()
18+
} else {
19+
reject(new Error(`${command} failed rc=${code}`))
20+
}
21+
})
22+
})
23+
}

fly.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# fly.toml app configuration file generated for devsnorte-landing-page-damp-waterfall-4609 on 2025-11-17T15:10:11-03:00
2+
#
3+
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
4+
#
5+
6+
app = 'devsnorte-landing-page-damp-waterfall-4609'
7+
primary_region = 'gru'
8+
9+
[build]
10+
11+
[http_service]
12+
internal_port = 3000
13+
force_https = true
14+
auto_stop_machines = 'stop'
15+
auto_start_machines = true
16+
min_machines_running = 0
17+
processes = ['app']
18+
19+
[[vm]]
20+
memory = '512mb'
21+
cpu_kind = 'shared'
22+
cpus = 1

0 commit comments

Comments
 (0)