diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..47719be --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +fly.toml +Dockerfile +.dockerignore +node_modules +.git diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index d01da7e..ef38fbc 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -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 diff --git a/.github/workflows/fly.yml b/.github/workflows/fly.yml new file mode 100644 index 0000000..29d5bca --- /dev/null +++ b/.github/workflows/fly.yml @@ -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 }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7c6f6b6 --- /dev/null +++ b/Dockerfile @@ -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" ] diff --git a/client/package.json b/client/package.json index 5072c31..3932fd0 100644 --- a/client/package.json +++ b/client/package.json @@ -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", diff --git a/fly.toml b/fly.toml new file mode 100644 index 0000000..1d22a3a --- /dev/null +++ b/fly.toml @@ -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"