Skip to content

Commit

Permalink
chore: create monorepo (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
pradel authored Jul 17, 2024
1 parent dfb18e2 commit 5d1e41f
Show file tree
Hide file tree
Showing 143 changed files with 317 additions and 190 deletions.
5 changes: 5 additions & 0 deletions .changeset/nasty-cycles-itch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"stackspulse": minor
---

Move stackspulse to a monorepo.
1 change: 1 addition & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
file: ./apps/web/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ jobs:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3

- name: Cache turbo build setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
Expand All @@ -43,4 +51,4 @@ jobs:
run: pnpm install

- name: Build
run: cp .env.production.build .env.production.local && pnpm build
run: cp ./apps/web/.env.production.build ./apps/web/.env.production.local && pnpm build
50 changes: 2 additions & 48 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,48 +1,2 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local
.env.keys
!.env.production.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

# Local Database
sqlite.db
sqlite.db-*

# Chainhooks
chainhooks.production.json

# Sentry Config File
.env.sentry-build-plugin
node_modules
.turbo
65 changes: 0 additions & 65 deletions Dockerfile

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
48 changes: 48 additions & 0 deletions apps/web/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local
.env.keys
!.env.production.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

# Local Database
sqlite.db
sqlite.db-*

# Chainhooks
chainhooks.production.json

# Sentry Config File
.env.sentry-build-plugin
File renamed without changes.
82 changes: 82 additions & 0 deletions apps/web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
ARG NODE_VERSION=20
FROM node:${NODE_VERSION}-alpine as base

WORKDIR /app

# Set production environment
ENV NODE_ENV="production"
ENV APP_NAME="stackspulse"

# Install pnpm
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
COPY --link ./package.json ./
RUN corepack enable && corepack install
RUN pnpm install turbo@^2 --global

# --- Turbo stage ---

FROM base AS builder
WORKDIR /app
RUN apk update && \
apk add --no-cache libc6-compat
COPY . .
RUN turbo prune $APP_NAME --docker

# --- Prod deps stage ---

# Optimize the node_modules production folder
FROM base AS prod-deps
COPY --link . .
# RUN node scripts/docker-runtime-deps.mjs
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod

# --- Build stage ---

FROM base as installer
WORKDIR /app

RUN apk update && \
apk add --no-cache libc6-compat build-base gyp pkgconfig python3

# First install the dependencies (as they change less often)
COPY .gitignore .gitignore
COPY --from=builder /app/out/json/ .
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile --prod=false

COPY --from=builder /app/out/full/ .

WORKDIR /app/apps/web

# Add fake environment file for build to succeed
COPY ./apps/web/.env.production.build .env.production.local
RUN pnpm db:push

# Build application
RUN pnpm turbo run build --filter=$APP_NAME...

# --- Runner stage ---

FROM base AS runner
WORKDIR /app

# Copy built application
COPY --from=prod-deps /app/apps/web/node_modules ./node_modules
COPY --from=installer /app/apps/web/package.json ./package.json
COPY --from=installer /app/apps/web/scripts ./scripts
COPY --from=installer /app/apps/web/drizzle.config.ts ./drizzle.config.ts
COPY --from=installer /app/apps/web/drizzle ./drizzle
COPY --from=prod-deps /app/apps/web/.env.production.local ./.env.production.local

COPY --from=installer /app/apps/web/.next/standalone ./
COPY --from=installer /app/apps/web/.next/static ./.next/static
COPY --from=installer /app/apps/web/public ./public

# Setup sqlite on a separate volume
RUN mkdir -p /data
VOLUME /data
ENV DATABASE_PATH="file:/data/sqlite.db"

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD pnpm dotenvx run -- node server.js
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
65 changes: 65 additions & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"name": "stackspulse",
"version": "0.5.2",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"chainhooks:generate": "dotenvx run --env-file=.env.production.local --env-file=.env.production -- node ./scripts/generate-chainhooks.mjs",
"db:generate": "drizzle-kit generate",
"db:push": "drizzle-kit push",
"db:migrate": "node ./scripts/drizzle-migrate.mjs",
"stacks-node:db:pull": "dotenvx run --env-file=.env.production.local --env-file=.env.production -- prisma db pull",
"deploy": "fly deploy --remote-only"
},
"dependencies": {
"@dotenvx/dotenvx": "1.6.1",
"@libsql/client": "0.4.3",
"@radix-ui/themes": "3.0.5",
"@sentry/nextjs": "8.17.0",
"@stacks/transactions": "6.16.1",
"@t3-oss/env-core": "0.10.1",
"@t3-oss/env-nextjs": "0.10.1",
"@tabler/icons-react": "3.10.0",
"@tanstack/react-query": "5.51.1",
"class-variance-authority": "0.7.0",
"clsx": "2.1.1",
"date-fns": "3.6.0",
"drizzle-orm": "0.32.0",
"fathom-client": "3.7.2",
"javascript-time-ago": "2.5.10",
"next": "14.2.5",
"postgres": "3.4.4",
"react": "18.3.1",
"react-dom": "18.3.1",
"recharts": "2.13.0-alpha.4",
"sharp": "0.33.4",
"tailwind-merge": "2.4.0",
"tailwindcss-animate": "1.0.7",
"twitter-api-v2": "1.17.1",
"unstorage": "1.10.2",
"zod": "3.23.8"
},
"devDependencies": {
"@flydotio/dockerfile": "0.5.8",
"@types/node": "20.14.10",
"@types/react": "18.3.3",
"@types/react-dom": "18.3.0",
"autoprefixer": "10.4.19",
"drizzle-kit": "0.23.0",
"eslint": "8.57.0",
"eslint-config-next": "14.2.5",
"eslint-plugin-tailwindcss": "3.17.4",
"postcss": "8.4.39",
"prisma": "5.16.2",
"radix-themes-tw": "0.2.3",
"tailwindcss": "3.4.4",
"typescript": "5.5.3"
},
"dockerfile": {
"alpine": true,
"secrets": ["CHAINHOOKS_API_TOKEN"]
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { dirname, join } from "node:path";
const __dirname = dirname(new URL(import.meta.url).pathname);
const packageJsonPath = join(__dirname, "..", "package.json");
const dependenciesToInstall = [
"husky",
"@libsql/client",
"drizzle-orm",
"@dotenvx/dotenvx",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 5d1e41f

Please sign in to comment.