Skip to content

Commit

Permalink
created actions
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwillmcleod committed Mar 11, 2024
1 parent 2f0b5aa commit b2c2204
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/deploy.production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Fly Deploy Production

on: [workflow_dispatch]

jobs:
# deploy-web:
# name: Deploy Web
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: superfly/flyctl-actions/setup-flyctl@master
# - run: flyctl deploy --remote-only --config fly.production.toml
# working-directory: ./web
# env:
# FLY_API_TOKEN: ${{ secrets.FLY_WEB_PRODUCTION_API_TOKEN }}

deploy-api:
name: Deploy Api
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only --config fly.production.toml
working-directory: ./api
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_PRODUCTION_API_TOKEN }}
29 changes: 29 additions & 0 deletions .github/workflows/deploy.staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Fly Deploy Staging

on:
push:
branches:
- main

jobs:
# deploy-web:
# name: Deploy Web
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: superfly/flyctl-actions/setup-flyctl@master
# - run: flyctl deploy --remote-only --config fly.staging.toml
# working-directory: ./web
# env:
# FLY_API_TOKEN: ${{ secrets.FLY_WEB_STAGING_API_TOKEN }}

deploy-api:
name: Deploy Api
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only --config fly.staging.toml
working-directory: ./api
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_STAGING_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.19.0
FROM node:${NODE_VERSION}-slim as base

LABEL fly_launch_runtime="Node.js"

# Node.js app lives here
WORKDIR /app

# Set production environment
ARG YARN_VERSION=1.22.19
RUN npm install -g yarn@$YARN_VERSION --force


# Throw-away build stage to reduce size of final image
FROM base as install

# 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.json yarn.lock tsconfig.json ./
COPY --link ./common ./common
COPY --link ./server ./server
RUN yarn install --frozen-lockfile

# Copy application code

FROM base as build

COPY --from=install /app /app

RUN yarn workspace server build

# 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
EXPOSE 8000
CMD [ "yarn", "workspace", "server", "serve" ]
18 changes: 18 additions & 0 deletions fly.production.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
app = 'wdcc-uasc-api'
primary_region = 'syd'

[build]
dockerfile = "Dockerfile"

[http_service]
internal_port = 8000
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ['app']

[[vm]]
cpu_kind = 'shared'
cpus = 4
memory_mb = 2048
18 changes: 18 additions & 0 deletions fly.staging.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
app = 'wdcc-uasc-api-staging'
primary_region = 'syd'

[build]
dockerfile = "Dockerfile"

[http_service]
internal_port = 8000
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ['app']

[[vm]]
cpu_kind = 'shared'
cpus = 1
memory_mb = 1024

0 comments on commit b2c2204

Please sign in to comment.