Skip to content

Commit

Permalink
Added fly.toml file for fly.io deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Ishannaik committed Apr 20, 2024
1 parent c6b52d9 commit 7edc554
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fly.toml
Dockerfile
.dockerignore
node_modules
.git
9 changes: 5 additions & 4 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Install dependencies and build
- name: Install dependencies and build client
run: |
cd server
npm install
cd server && npm run build
npm run build
working-directory: client

- name: Deploy to GitHub Pages

uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GH_PAGES_TOKEN }}
publish_dir: ../client/dist
publish_dir: client/dist
16 changes: 16 additions & 0 deletions .github/workflows/fly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Fly Deploy
on:
push:
branches:
- main # change to main if needed
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 }}
39 changes: 39 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# syntax = docker/dockerfile:1

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

LABEL fly_launch_runtime="NodeJS"

# NodeJS app lives here
WORKDIR /app

# Set production environment
ENV NODE_ENV=production


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

# Install node modules
COPY --link package.json package-lock.json .
RUN npm install

# Copy application code
COPY --link . .



# Final stage for app image
FROM base

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

# Start the server by default, this can be overwritten at runtime
CMD [ "npm", "run", "start" ]
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "brainwave",
"private": false,
"version": "0.0.2",
"homepage": "https://ishannaik.github.io/brainwave/",
"homepage": "https://ishannaik.github.io/brainwave",
"type": "module",
"scripts": {
"predeploy": "npm run build",
Expand Down
23 changes: 23 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# fly.toml app configuration file generated for brainwave on 2024-04-20T10:53:34+05:30
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = "brainwave"
primary_region = "sin"

[env]
PORT = "8080"

[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = true
auto_start_machines = true

[checks]
[checks.alive]
type = "tcp"
interval = "15s"
timeout = "2s"
grace_period = "5s"

0 comments on commit 7edc554

Please sign in to comment.