feat: move back to yarn and finally fix builds

This commit is contained in:
2025-03-22 15:34:10 +01:00
parent e57312e48f
commit 981b0b8b77
10 changed files with 5524 additions and 88 deletions

41
.dockerignore Normal file
View File

@@ -0,0 +1,41 @@
# Version control
.git
.gitignore
# Dependencies
**/node_modules
.pnpm-store
# Build outputs
**/dist
**/.next
**/build
**/out
# Development files
**/.env*
!**/.env.example
**/.vscode
**/.idea
**/coverage
**/.turbo
**/.cache
# System files
.DS_Store
**/Thumbs.db
# Logs
**/npm-debug.log*
**/yarn-debug.log*
**/yarn-error.log*
**/pnpm-debug.log*
# Test files
**/__tests__
**/*.test.*
**/*.spec.*
packages/db/generated
dev/
flv-module/

View File

@@ -1,35 +0,0 @@
# Ignore node_modules and build output
node_modules
.next
out
# Ignore logs and temporary files
*.log
*.tmp
*.swp
# Ignore local environment files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local
# Ignore Docker files
Dockerfile
docker-compose.yml
# Ignore git files
.git
.gitignore
# Ignore editor directories and files
.vscode
.idea
*.sublime-project
*.sublime-workspace
# Ignore other unnecessary files
README.md
dev/
flv-module/

View File

@@ -1,44 +1,45 @@
FROM oven/bun:alpine AS builder FROM node:lts-alpine AS base
FROM base AS builder
RUN apk update
RUN apk add --no-cache libc6-compat
# Set working directory
WORKDIR /app WORKDIR /app
# Replace <your-major-version> with the major version installed in your repository. For example:
# Copy package files # RUN yarn global add turbo@^2
COPY package.json bun.lockb ./ RUN yarn global add turbo@^2
# Install dependencies
RUN bun install
# Copy app files
COPY . . COPY . .
# Build app # Generate a partial monorepo with a pruned lockfile for a target workspace.
RUN bun run build # Assuming "web" is the name entered in the project's package.json: { name: "web" }
RUN turbo prune @hctv/web --docker
# Stage 2: Production
FROM oven/bun:alpine AS runner
# Add lockfile and package.json's of isolated subworkspace
FROM base AS installer
RUN apk update
RUN apk add --no-cache libc6-compat
WORKDIR /app WORKDIR /app
ENV NODE_ENV=production # First install the dependencies (as they change less often)
COPY --from=builder /app/out/json/ .
RUN yarn install --frozen-lockfile
# Copy necessary files # Build the project
COPY --from=builder /app/next.config.mjs ./ COPY --from=builder /app/out/full/ .
COPY --from=builder /app/package.json ./ RUN yarn turbo run build
COPY --from=builder /app/bun.lockb ./
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/prisma ./prisma
COPY --from=builder /app/node_modules ./node_modules
# Install production dependencies only FROM base AS runner
RUN apk add --no-cache openssl WORKDIR /app
RUN bun pm cache rm && bun run prepare
# Remove unnecessary files # Don't run production as root
RUN rm -rf /app/.git \ RUN addgroup --system --gid 1001 nodejs
/app/.next/cache \ RUN adduser --system --uid 1001 nextjs
/app/README.md USER nextjs
EXPOSE 3000 # Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/standalone ./
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/public ./apps/web/public
CMD ["bun", "start"] CMD node apps/web/server.js

View File

@@ -1,4 +1,12 @@
const LIVE_SERVER_URL = process.env.NODE_ENV === 'production' ? 'https://backend.hctv.srizan.dev' : 'http://localhost:8888' import * as path from 'node:path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const LIVE_SERVER_URL =
process.env.NODE_ENV === 'production'
? 'https://backend.hctv.srizan.dev'
: 'http://localhost:8888';
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
const nextConfig = { const nextConfig = {
images: { images: {
@@ -8,13 +16,15 @@ const nextConfig = {
}, },
{ {
hostname: 'secure.gravatar.com', hostname: 'secure.gravatar.com',
} },
] ],
}, },
env: { env: {
LIVE_SERVER_URL, LIVE_SERVER_URL,
}, },
reactStrictMode: false, reactStrictMode: false,
output: 'standalone',
outputFileTracingRoot: path.join(__dirname, '../../'),
}; };
export default nextConfig; export default nextConfig;

View File

@@ -15,7 +15,7 @@
"check-types": "tsc --noEmit" "check-types": "tsc --noEmit"
}, },
"dependencies": { "dependencies": {
"@hctv/db": "workspace:*", "@hctv/db": "*",
"@hookform/resolvers": "^3.9.1", "@hookform/resolvers": "^3.9.1",
"@livekit/components-react": "^2.7.0", "@livekit/components-react": "^2.7.0",
"@lucia-auth/adapter-prisma": "^4.0.1", "@lucia-auth/adapter-prisma": "^4.0.1",

View File

@@ -1,5 +1,5 @@
import { validateRequest } from "."; import { validateRequest } from ".";
import prisma from "../db"; import prisma from '@hctv/db';
export async function getPersonalChannel(id?: string) { export async function getPersonalChannel(id?: string) {
const { user } = await validateRequest(); const { user } = await validateRequest();

View File

@@ -10,10 +10,11 @@
"scripts": { "scripts": {
"build": "turbo run build", "build": "turbo run build",
"dev": "turbo run dev", "dev": "turbo run dev",
"lint": "turbo run lint" "lint": "turbo run lint",
"docker:web": "docker build -t srizan10/hclive -f apps/web/Dockerfile ."
}, },
"devDependencies": { "devDependencies": {
"turbo": "^2.4.4" "turbo": "^2.4.4"
}, },
"packageManager": "pnpm@10.6.5" "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
} }

View File

@@ -1,3 +0,0 @@
packages:
- packages/*
- apps/*

View File

@@ -2,7 +2,7 @@
"$schema": "https://turbo.build/schema.json", "$schema": "https://turbo.build/schema.json",
"tasks": { "tasks": {
"build": { "build": {
"dependsOn": ["^db:generate", "^build"], "dependsOn": ["^db:generate", "prepare"],
"outputs": [".next/**", "!.next/cache/**"] "outputs": [".next/**", "!.next/cache/**"]
}, },
"setup": { "setup": {
@@ -17,7 +17,7 @@
"dependsOn": ["^check-types"] "dependsOn": ["^check-types"]
}, },
"dev": { "dev": {
"dependsOn": ["^dd", "db:generate"], "dependsOn": ["dd", "db:generate"],
"persistent": true, "persistent": true,
"cache": false "cache": false
}, },
@@ -34,6 +34,9 @@
}, },
"db:deploy": { "db:deploy": {
"cache": false "cache": false
},
"prepare": {
"cache": false
} }
} }
} }

5418
yarn.lock Normal file

File diff suppressed because it is too large Load Diff