Skip to content

Commit e028606

Browse files
committed
feat: add fly deploy config
1 parent b6b9887 commit e028606

File tree

24 files changed

+2758
-9562
lines changed

24 files changed

+2758
-9562
lines changed

.dockerignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
.yarn/install-state.gz
8+
9+
# testing
10+
/coverage
11+
12+
# next.js
13+
/.next/
14+
/out/
15+
16+
# production
17+
/build
18+
19+
# misc
20+
.DS_Store
21+
*.pem
22+
23+
# debug
24+
npm-debug.log*
25+
yarn-debug.log*
26+
yarn-error.log*
27+
28+
# local env files
29+
.env*.local
30+
.env
31+
.env.deploy
32+
33+
# vercel
34+
.vercel
35+
36+
# typescript
37+
*.tsbuildinfo
38+
next-env.d.ts
39+
40+
.vscode

.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 }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ yarn-error.log*
2828
# local env files
2929
.env*.local
3030
.env
31+
.env.deploy
3132

3233
# vercel
3334
.vercel

Dockerfile

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# syntax = docker/dockerfile:1
2+
3+
# Adjust NODE_VERSION as desired
4+
ARG NODE_VERSION=20.13.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+
ARG NEXT_PUBLIC_GRAPHQL_API_URL
15+
ENV NEXT_PUBLIC_GRAPHQL_API_URL=$NEXT_PUBLIC_GRAPHQL_API_URL
16+
17+
ARG NEXT_PUBLIC_MAPBOX_KEY
18+
ENV NEXT_PUBLIC_MAPBOX_KEY=$NEXT_PUBLIC_MAPBOX_KEY
19+
20+
ARG NEXT_PUBLIC_TRACKING_ACTIVATED
21+
ENV NEXT_PUBLIC_TRACKING_ACTIVATED=$NEXT_PUBLIC_TRACKING_ACTIVATED
22+
23+
ARG NEXT_PUBLIC_SANITY_API_VERSION
24+
ENV NEXT_PUBLIC_SANITY_API_VERSION=$NEXT_PUBLIC_SANITY_API_VERSION
25+
26+
ARG NEXT_PUBLIC_SANITY_DATASET
27+
ENV NEXT_PUBLIC_SANITY_DATASET=$NEXT_PUBLIC_SANITY_DATASET
28+
29+
ARG NEXT_PUBLIC_SANITY_PROJECT_ID
30+
ENV NEXT_PUBLIC_SANITY_PROJECT_ID=$NEXT_PUBLIC_SANITY_PROJECT_ID
31+
32+
ARG NEXT_PUBLIC_CLERK_SIGN_IN_URL
33+
ENV NEXT_PUBLIC_CLERK_SIGN_IN_URL=$NEXT_PUBLIC_CLERK_SIGN_IN_URL
34+
35+
ARG NEXT_PUBLIC_CLERK_SIGN_UP_URL
36+
ENV NEXT_PUBLIC_CLERK_SIGN_UP_URL=$NEXT_PUBLIC_CLERK_SIGN_UP_URL
37+
38+
ARG NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
39+
ENV NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=$NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
40+
41+
ARG NEXT_PUBLIC_ENABLED_MENU_ITEMS
42+
ENV NEXT_PUBLIC_ENABLED_MENU_ITEMS=$NEXT_PUBLIC_ENABLED_MENU_ITEMS
43+
44+
# Install pnpm
45+
ARG PNPM_VERSION=9.9.0
46+
RUN npm install -g pnpm@$PNPM_VERSION
47+
48+
49+
# Throw-away build stage to reduce size of final image
50+
FROM base as build
51+
52+
# Install packages needed to build node modules
53+
RUN apt-get update -qq && \
54+
apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3
55+
56+
# Install node modules
57+
COPY .npmrc package-lock.json package.json pnpm-lock.yaml ./
58+
RUN pnpm install --frozen-lockfile --prod=false
59+
60+
# Copy application code
61+
COPY . .
62+
63+
# Build application
64+
RUN pnpm run build
65+
66+
# Remove development dependencies
67+
RUN pnpm prune --prod
68+
69+
70+
# Final stage for app image
71+
FROM base
72+
73+
# Copy built application
74+
COPY --from=build /app /app
75+
76+
# Start the server by default, this can be overwritten at runtime
77+
EXPOSE 3000
78+
CMD [ "pnpm", "run", "start" ]

deploy.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
# Initialize variables
4+
CONFIG_FILE=""
5+
6+
# Parse command line arguments
7+
while getopts ":c:" opt; do
8+
case $opt in
9+
c)
10+
CONFIG_FILE="-c $OPTARG"
11+
;;
12+
\?)
13+
echo "Invalid option: -$OPTARG" >&2
14+
exit 1
15+
;;
16+
:)
17+
echo "Option -$OPTARG requires an argument." >&2
18+
exit 1
19+
;;
20+
esac
21+
done
22+
23+
# Read .env file
24+
set -a
25+
source .env.deploy
26+
set +a
27+
28+
# Construct build args string
29+
BUILD_ARGS=""
30+
for var in "${!NEXT_PUBLIC_@}"; do
31+
BUILD_ARGS="$BUILD_ARGS --build-arg $var=${!var}"
32+
done
33+
34+
# Deploy with build args and optional config file
35+
echo "Deploying with command: fly deploy $CONFIG_FILE $BUILD_ARGS"
36+
fly deploy $CONFIG_FILE $BUILD_ARGS

fly-debug.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 debug-ccrp-front on 2024-10-08T16:17:32+02:00
2+
#
3+
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
4+
#
5+
6+
app = 'debug-ccrp-front'
7+
primary_region = 'cdg'
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 = '1gb'
21+
cpu_kind = 'shared'
22+
cpus = 1

fly.toml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# fly.toml app configuration file generated for debug-ccrp-front on 2024-10-08T16:17:32+02:00
2+
#
3+
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
4+
#
5+
6+
app = 'ccrp-front'
7+
primary_region = 'cdg'
8+
9+
[build]
10+
[build.args]
11+
NEXT_PUBLIC_GRAPHQL_API_URL = ""
12+
NEXT_PUBLIC_MAPBOX_KEY = ""
13+
NEXT_PUBLIC_TRACKING_ACTIVATED = ""
14+
NEXT_PUBLIC_SANITY_API_VERSION = ""
15+
NEXT_PUBLIC_SANITY_DATASET = ""
16+
NEXT_PUBLIC_SANITY_PROJECT_ID = ""
17+
NEXT_PUBLIC_CLERK_SIGN_IN_URL = ""
18+
NEXT_PUBLIC_CLERK_SIGN_UP_URL = ""
19+
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY = ""
20+
NEXT_PUBLIC_ENABLED_MENU_ITEMS = ""
21+
22+
[http_service]
23+
internal_port = 3000
24+
force_https = true
25+
auto_stop_machines = 'stop'
26+
auto_start_machines = true
27+
min_machines_running = 0
28+
processes = ['app']
29+
30+
[[vm]]
31+
memory = '1gb'
32+
cpu_kind = 'shared'
33+
cpus = 1

next.config.mjs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,4 @@ const requiredEnvVars = [
1212
'CLERK_SECRET_KEY',
1313
];
1414

15-
requiredEnvVars.forEach((envVar) => {
16-
if (!process.env[envVar]) {
17-
throw new Error(
18-
`Environment variable ${envVar} is missing! Please set it before starting the application.`,
19-
);
20-
}
21-
});
22-
2315
export default nextConfig;

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818
"@graphql-codegen/cli": "^5.0.2",
1919
"@graphql-codegen/client-preset": "^4.3.3",
2020
"@graphql-tools/schema": "^10.0.6",
21+
"@graphql-typed-document-node/core": "^3.2.0",
2122
"@headlessui/react": "^2.1.3",
2223
"@heroicons/react": "^2.1.5",
2324
"@nextui-org/react": "^2.4.6",
2425
"@portabletext/react": "^3.1.0",
2526
"@sanity/image-url": "^1.0.2",
2627
"framer-motion": "^11.3.17",
28+
"graphql": "^16.9.0",
2729
"mapbox-gl": "^3.6.0",
2830
"moment": "^2.30.1",
2931
"next": "14.2.4",
@@ -35,6 +37,7 @@
3537
"recharts": "^2.12.7"
3638
},
3739
"devDependencies": {
40+
"@flydotio/dockerfile": "^0.5.9",
3841
"@types/node": "^20",
3942
"@types/react": "^18",
4043
"@types/react-dom": "^18",

0 commit comments

Comments
 (0)