Skip to content

Commit

Permalink
[DevOps] Deploy to Fly.io (#1657)
Browse files Browse the repository at this point in the history
* chore: dockerfile

* build(deps): update package.json and yarn.lock

* fly configuration

* build(deps): update yarn.lock

* build: update .dockerignore

* build: update Dockerfile
  • Loading branch information
paradoxe35 authored Oct 26, 2023
1 parent 25ad6fd commit 6a1036d
Show file tree
Hide file tree
Showing 6 changed files with 295 additions and 8 deletions.
34 changes: 34 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ docker-compose*.yml
.gitignore
Jenkinsfile

**/.next
**/build
**/node_modules/*
**/dist
**/out

**/*.log

**/.vscode
**/.env.local
**/.env*.local

fly.toml

node_modules

apps/mobile/node_modules
Expand All @@ -40,3 +54,23 @@ e2e/*.map
#System Files
.DS_Store
Thumbs.db

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# vercel
.vercel

# typescript
*.tsbuildinfo

Check warning on line 72 in .dockerignore

View workflow job for this annotation

GitHub Actions / Cspell

Unknown word (tsbuildinfo)
next-env.d.ts

# Sentry Auth Token
.sentryclirc

Check warning on line 76 in .dockerignore

View workflow job for this annotation

GitHub Actions / Cspell

Unknown word (sentryclirc)
57 changes: 57 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# syntax = docker/dockerfile:1

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


# Next.js app lives here
WORKDIR /app

# Set production environment
ENV NEXT_SHARP_PATH=/app/node_modules/sharp


# 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 -y build-essential pkg-config python-is-python3

# Install Yarn
RUN npm install -g yarn --force

# Install node modules
COPY --link package.json ./
COPY --link yarn.lock ./
COPY --link apps/web/package.json ./apps/web/package.json

RUN cd apps/web && \
yarn install --ignore-scripts

# Copy application code
COPY --link . .

ENV NODE_ENV="production"

# Build application
RUN yarn run build:web

# Remove development dependencies
RUN cd apps/web && \
yarn install --prod --ignore-scripts


# Final stage for app image
FROM base

ENV NODE_ENV="production"

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

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000

CMD [ "npm", "run", "start:web" ]
13 changes: 10 additions & 3 deletions apps/web/next.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
const path = require('path');

// eslint-disable-next-line @typescript-eslint/no-var-requires
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
webpack: (config, { isServer }) => {
config.resolve.alias['@app'] = path.join(__dirname, 'app');
config.resolve.alias['@components'] = path.join(__dirname, 'components');
config.resolve.alias['app'] = path.join(__dirname, 'app');
config.resolve.alias['components'] = path.join(__dirname, 'components');
config.resolve.alias['lib'] = path.join(__dirname, 'lib');
return config;
},
images: {
domains: [
'dummyimage.com',
Expand All @@ -14,9 +24,6 @@ const nextConfig = {
'apistage.gauzy.co',

Check warning on line 24 in apps/web/next.config.js

View workflow job for this annotation

GitHub Actions / Cspell

Unknown word (apistage)
'gauzy.s3.wasabisys.com'

Check warning on line 25 in apps/web/next.config.js

View workflow job for this annotation

GitHub Actions / Cspell

Unknown word (wasabisys)
]
},
experimental: {
appDir: true
}
};

Expand Down
1 change: 1 addition & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"react-popper": "^2.3.0",
"react-popper-tooltip": "^4.4.2",
"recoil": "^0.7.7",
"sharp": "^0.32.6",
"slate": "^0.90.0",
"slate-history": "^0.93.0",
"slate-hyperscript": "^0.77.0",
Expand Down
19 changes: 19 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# fly.toml app configuration file generated for ever-teams on 2023-10-26T08:19:45Z
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = "ever-teams"
primary_region = "lax"
kill_signal = "SIGINT"
kill_timeout = "5m0s"

[build]

[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ["app"]
Loading

0 comments on commit 6a1036d

Please sign in to comment.