Skip to content

Commit

Permalink
Merge pull request #144 from room302studio/fly-io-deploy
Browse files Browse the repository at this point in the history
build: deploy to fly.io
  • Loading branch information
ejfox authored Jul 10, 2024
2 parents 5d6d792 + 097401e commit 4bc3d7e
Show file tree
Hide file tree
Showing 6 changed files with 290 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.env
node_modules/
summaries/*.txt
coachartiegithub.2023-05-02.private-key.pem

/cache/*
/capabilities/cache/*
*.log
artie.log
capabilities/cache/*.json
/cache/*.json

auth/coach-artie-5f8c6debae41.json
auth/coach-artie-e95c8660132f.json
auth/coach-artie-*.json
.idea
.DS_Store
18 changes: 18 additions & 0 deletions .github/workflows/fly-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# See https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/

name: Fly Deploy
on:
push:
branches:
- main
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 }}
45 changes: 45 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# syntax = docker/dockerfile:1

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

LABEL fly_launch_runtime="Node.js"

# Node.js 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 --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3

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

# Copy application code
COPY --link . .


# Final stage for app image
FROM base

# Install packages needed for deployment
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y chromium chromium-sandbox && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives

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

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
ENV PUPPETEER_EXECUTABLE_PATH="/usr/bin/chromium"
CMD [ "npm", "run", "start" ]
26 changes: 26 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# fly.toml app configuration file generated for coachartie-discord on 2024-07-10T10:33:10-04:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = "coachartie-discord"
primary_region = "ewr"

[build]

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

[[vm]]
memory = "1gb"
cpu_kind = "shared"
cpus = 1

[processes]
web = "npm run web"
discord = "npm run start"
183 changes: 183 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"xml-js": "^1.6.11"
},
"devDependencies": {
"@flydotio/dockerfile": "^0.5.7",
"documentation": "^14.0.2",
"jest": "^29.6.4",
"nodemon": "^3.1.0"
Expand Down

0 comments on commit 4bc3d7e

Please sign in to comment.