mirror of
https://github.com/hanzoai/captable.git
synced 2026-10-16 14:21:29 +00:00
feat: improve deployment workflow (#318)
* chore: remove docker.fly * feat: remove deploy workflow * feat: add staging deploy * feat: add production deploy * feat: move docker file * feat: add experimental and release command * chore: use emoji and update node version * fix: enable action * feat: testing staging and prod deploys * chore: setup fly before deploy * feat: testing staging deploy * feat: deploy latest docker image instead of re-building it * fix: app name during deploy * feat: fixing command * feat: another try to fix the command * feat: rename file and build image before deploy for staging workflow * fix: updating release command * fix: try bash file * fix: command * fix: bash to sh * feat: add docker setup for app as well * feat: update docker compose * feat: working with docker compose for developer dx * chore: final cleanup --------- Co-authored-by: Puru D <[email protected]>
This commit is contained in:
committed by
GitHub
co-authored by
Puru D
parent
6d13b05660
commit
dfc56bf466
@@ -3,11 +3,11 @@ name: "Build captable app"
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Copy env
|
||||
- name: 🏄 Copy example env vars
|
||||
shell: bash
|
||||
run: cp .env.example .env
|
||||
|
||||
- name: Build app
|
||||
- name: 🏗 Build
|
||||
shell: bash
|
||||
run: npx prisma generate && npm run build
|
||||
env:
|
||||
|
||||
@@ -2,25 +2,25 @@ name: "Setup node and cache node_modules"
|
||||
inputs:
|
||||
node_version:
|
||||
required: false
|
||||
default: v18.x
|
||||
default: v20.x
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Set up Node ${{ inputs.node_version }}
|
||||
- name: ⎔ Setup node ${{ inputs.node_version }}
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ inputs.node_version }}
|
||||
cache: npm
|
||||
|
||||
- name: Cache node_modules
|
||||
- name: 📥 Cache deps
|
||||
uses: actions/cache@v4
|
||||
id: cache-node-modules
|
||||
with:
|
||||
path: node_modules
|
||||
key: modules-${{ hashFiles('package-lock.json') }}
|
||||
|
||||
- name: Install dependencies
|
||||
- name: 📥 Install deps
|
||||
if: steps.cache-node-modules.outputs.cache-hit != 'true'
|
||||
shell: bash
|
||||
run: npm ci --no-audit
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
name: "Continuous Integration"
|
||||
name: "Build docker image"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: ["main"]
|
||||
|
||||
jobs:
|
||||
build_app:
|
||||
name: Build App
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 2
|
||||
# build_app:
|
||||
# name: Build App
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - name: Checkout
|
||||
# uses: actions/checkout@v4
|
||||
# with:
|
||||
# fetch-depth: 2
|
||||
|
||||
- uses: ./.github/actions/node-setup
|
||||
# - uses: ./.github/actions/node-setup
|
||||
|
||||
- uses: ./.github/actions/build-app
|
||||
# - uses: ./.github/actions/build-app
|
||||
|
||||
build_docker:
|
||||
name: Build Docker Image
|
||||
@@ -1,20 +0,0 @@
|
||||
name: Fly Deploy
|
||||
env:
|
||||
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
|
||||
on:
|
||||
push:
|
||||
# branches:
|
||||
# - main
|
||||
branches:
|
||||
- 'disabled/**'
|
||||
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 }}
|
||||
@@ -0,0 +1,30 @@
|
||||
name: Fly Production Deploy
|
||||
env:
|
||||
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
name: 🚀 Deploy
|
||||
runs-on: ubuntu-latest
|
||||
concurrency: deploy-group # optional: ensure only one action runs at a time
|
||||
steps:
|
||||
- name: ⬇️ Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: 🚚 Move Dockerfile to root
|
||||
run: |
|
||||
mv ./docker/Dockerfile ./Dockerfile
|
||||
|
||||
- name: 🪰 Setup flyctl
|
||||
uses: superfly/flyctl-actions/setup-flyctl@master
|
||||
with:
|
||||
version: latest
|
||||
|
||||
- name: 🚀 Deploy Production
|
||||
run: flyctl deploy --remote-only --build-arg COMMIT_SHA=${{ github.sha }}
|
||||
env:
|
||||
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
|
||||
@@ -15,23 +15,23 @@ jobs:
|
||||
attestations: write
|
||||
|
||||
steps:
|
||||
- name: Check out the repo
|
||||
- name: ✅ Check out the repo
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
- name: 🐬 Log in to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Log in to the Container registry
|
||||
- name: 🗄️ Log in to the Container registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
- name: 🗃️ Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
@@ -39,7 +39,7 @@ jobs:
|
||||
captable/captable
|
||||
ghcr.io/${{ github.repository }}
|
||||
|
||||
- name: Build and push Docker images
|
||||
- name: 🚀 Build and push Docker images
|
||||
id: push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
name: Fly Staging Deploy
|
||||
env:
|
||||
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
name: 🚀 Deploy
|
||||
runs-on: ubuntu-latest
|
||||
concurrency: deploy-group # optional: ensure only one action runs at a time
|
||||
steps:
|
||||
- name: ⬇️ Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: 👀 Read app name
|
||||
uses: SebRollen/[email protected]
|
||||
id: app_name
|
||||
with:
|
||||
file: "fly.toml"
|
||||
field: "app"
|
||||
|
||||
- name: 🚚 Move Dockerfile to root
|
||||
run: |
|
||||
mv ./docker/Dockerfile ./Dockerfile
|
||||
|
||||
- name: 🪰 Setup flyctl
|
||||
uses: superfly/flyctl-actions/setup-flyctl@master
|
||||
with:
|
||||
version: latest
|
||||
|
||||
- name: 🚀 Deploy Staging
|
||||
run:
|
||||
flyctl deploy --remote-only --build-arg COMMIT_SHA=${{ github.sha }}
|
||||
--app ${{ steps.app_name.outputs.value }}-staging
|
||||
env:
|
||||
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
|
||||
+2
-2
@@ -14,10 +14,10 @@ ports:
|
||||
- port: 3000
|
||||
visibility: public
|
||||
onOpen: open-preview
|
||||
- port: 9000
|
||||
- port: 8025
|
||||
visibility: public
|
||||
onOpen: ignore
|
||||
- port: 1100
|
||||
- port: 1025
|
||||
visibility: private
|
||||
onOpen: ignore
|
||||
- port: 2500
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
# syntax = docker/dockerfile:1
|
||||
|
||||
# Adjust NODE_VERSION as desired
|
||||
ARG NODE_VERSION=20.11.0
|
||||
FROM node:${NODE_VERSION}-slim as base
|
||||
|
||||
LABEL fly_launch_runtime="Next.js/Prisma"
|
||||
|
||||
# Next.js/Prisma app lives here
|
||||
WORKDIR /app
|
||||
|
||||
# Set production environment
|
||||
# ENV NODE_ENV="production"
|
||||
ENV SKIP_ENV_VALIDATION=true
|
||||
|
||||
|
||||
# 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 openssl pkg-config python-is-python3
|
||||
|
||||
# Install node modules
|
||||
COPY --link package-lock.json package.json ./
|
||||
RUN npm ci --include=dev
|
||||
|
||||
# Generate Prisma Client
|
||||
COPY --link prisma/enum-generator.cjs ./prisma/enum-generator.cjs
|
||||
COPY --link prisma ./
|
||||
RUN npx prisma generate
|
||||
|
||||
# Copy application code
|
||||
# COPY --link prisma/enums.ts ./prisma/enums.ts
|
||||
COPY --link . .
|
||||
|
||||
# Build application
|
||||
RUN npm run build
|
||||
|
||||
# Remove development dependencies
|
||||
RUN npm prune --omit=dev
|
||||
|
||||
|
||||
# Final stage for app image
|
||||
FROM base
|
||||
|
||||
# Install packages needed for deployment
|
||||
RUN apt-get update -qq && \
|
||||
apt-get install --no-install-recommends -y openssl && \
|
||||
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
|
||||
CMD [ "npm", "run", "start" ]
|
||||
@@ -18,8 +18,8 @@
|
||||
<a href="https://twitter.com/captableinc">
|
||||
<img src="https://img.shields.io/twitter/follow/captableinc?style=flat&label=%40Captable, Inc.&logo=twitter&color=0bf&logoColor=0bf" alt="Twitter" />
|
||||
</a>
|
||||
<a href="https://github.com/captableinc/captable/actions/workflows/deploy.yml">
|
||||
<img src="https://github.com/captableinc/captable/actions/workflows/deploy.yml/badge.svg?branch=main&title=CI" alt="CI" />
|
||||
<a href="https://github.com/captableinc/captable/actions/workflows/release.yml">
|
||||
<img src="https://github.com/captableinc/captable/actions/workflows/release.yml/badge.svg?branch=main&title=CI" alt="CI" />
|
||||
</a>
|
||||
<a href="https://github.com/captableinc/captable/blob/main/LICENSE">
|
||||
<img src="https://img.shields.io/github/license/captableinc/captable?label=license&logo=github&color=f80&logoColor=fff" alt="License" />
|
||||
@@ -79,7 +79,7 @@ cp .env.example .env
|
||||
* SMTP server
|
||||
|
||||
```sh
|
||||
npm run docker:start
|
||||
npm run dx
|
||||
```
|
||||
|
||||
Generate tables and the Prisma client.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
name: captable
|
||||
services:
|
||||
database:
|
||||
pg:
|
||||
image: postgres:15
|
||||
container_name: captable-database
|
||||
environment:
|
||||
@@ -12,14 +12,12 @@ services:
|
||||
volumes:
|
||||
- postgres_raw:/var/lib/postgresql/data
|
||||
|
||||
inbucket:
|
||||
image: inbucket/inbucket
|
||||
container_name: captable-mailserver
|
||||
smtp:
|
||||
image: axllent/mailpit
|
||||
container_name: captable-smtp
|
||||
ports:
|
||||
- 9000:9000
|
||||
- 2500:2500
|
||||
- 1100:1100
|
||||
|
||||
- 8025:8025
|
||||
- 1025:1025
|
||||
minio:
|
||||
image: minio/minio
|
||||
container_name: captable-minio
|
||||
@@ -34,7 +32,27 @@ services:
|
||||
entrypoint: sh
|
||||
command: -c 'minio server /data --console-address ":9001" --address ":9002"'
|
||||
|
||||
# app:
|
||||
# build:
|
||||
# context: .
|
||||
# dockerfile: ./docker/Dockerfile.dev
|
||||
# container_name: captable-app
|
||||
# ports:
|
||||
# - 3000:3000
|
||||
# env_file:
|
||||
# - ".env.example"
|
||||
# - ".env"
|
||||
# volumes:
|
||||
# - ./:/opt/captable
|
||||
# - node_modules:/opt/captable/node_modules
|
||||
# - dist:/opt/captable/dist
|
||||
|
||||
# depends_on:
|
||||
# - pg
|
||||
# - smtp
|
||||
# - minio
|
||||
|
||||
# minio client - is expected to be run once to setup minio buckets. It'll exit 0 after setup
|
||||
mc:
|
||||
image: minio/mc
|
||||
container_name: captable-minio-client
|
||||
@@ -52,3 +70,5 @@ services:
|
||||
volumes:
|
||||
minio:
|
||||
postgres_raw:
|
||||
node_modules:
|
||||
dist:
|
||||
@@ -0,0 +1,11 @@
|
||||
FROM node:20-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY ../package.json ./
|
||||
|
||||
RUN npm install
|
||||
|
||||
COPY . .
|
||||
|
||||
CMD ["npm", "run", "dev"]
|
||||
@@ -6,25 +6,27 @@
|
||||
app = 'captable'
|
||||
primary_region = 'lax'
|
||||
|
||||
[build]
|
||||
dockerfile = "Dockerfile.fly"
|
||||
ignorefile = ".dockerignore"
|
||||
|
||||
[experimental]
|
||||
allowed_public_ports = []
|
||||
auto_rollback = true
|
||||
|
||||
[http_service]
|
||||
internal_port = 3000
|
||||
force_https = true
|
||||
auto_stop_machines = true
|
||||
auto_start_machines = true
|
||||
min_machines_running = 0
|
||||
processes = ['app']
|
||||
internal_port = 3000
|
||||
force_https = true
|
||||
auto_stop_machines = true
|
||||
auto_start_machines = true
|
||||
min_machines_running = 0
|
||||
processes = ['app']
|
||||
|
||||
[[vm]]
|
||||
memory = '1gb'
|
||||
cpu_kind = 'shared'
|
||||
cpus = 1
|
||||
memory = '1gb'
|
||||
cpu_kind = 'shared'
|
||||
cpus = 1
|
||||
|
||||
[deploy]
|
||||
strategy = "canary"
|
||||
strategy = "canary"
|
||||
# release_command = "npx prisma migrate deploy"
|
||||
|
||||
[env]
|
||||
NODE_ENV = "production"
|
||||
NODE_ENV = "production"
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
"scripts": {
|
||||
"prepare": "husky install",
|
||||
"build": "next build",
|
||||
"docker:start": "docker-compose -f docker/docker-compose.yml up -d",
|
||||
"dx": "docker-compose -f compose.yml up -d",
|
||||
"db:push": "npx prisma db push",
|
||||
"db:studio": "npx prisma studio",
|
||||
"db:migrate": "npx prisma migrate dev",
|
||||
|
||||
Reference in New Issue
Block a user