mirror of
https://github.com/SrIzan10/hctv.git
synced 2026-06-06 00:56:56 +00:00
feat: docker stuff
This commit is contained in:
37
.github/workflows/docker.yml
vendored
37
.github/workflows/docker.yml
vendored
@@ -76,10 +76,45 @@ jobs:
|
|||||||
secrets: |
|
secrets: |
|
||||||
TURBO_TOKEN=${{ secrets.TURBO_TOKEN }}
|
TURBO_TOKEN=${{ secrets.TURBO_TOKEN }}
|
||||||
TURBO_TEAM=${{ secrets.TURBO_TEAM }}
|
TURBO_TEAM=${{ secrets.TURBO_TEAM }}
|
||||||
|
chat:
|
||||||
|
name: Push chat module to Docker Hub
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out the repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Log in to Docker Hub
|
||||||
|
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
|
||||||
|
with:
|
||||||
|
images: srizan10/hclive-chat
|
||||||
|
tags: latest
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./apps/chat/Dockerfile
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
platforms: linux/amd64
|
||||||
|
secrets: |
|
||||||
|
TURBO_TOKEN=${{ secrets.TURBO_TOKEN }}
|
||||||
|
TURBO_TEAM=${{ secrets.TURBO_TEAM }}
|
||||||
deploy:
|
deploy:
|
||||||
name: Deploy to server
|
name: Deploy to server
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [frontend, db]
|
needs: [frontend, db, chat]
|
||||||
steps:
|
steps:
|
||||||
- name: Emit a webhook to the server
|
- name: Emit a webhook to the server
|
||||||
env:
|
env:
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -40,4 +40,5 @@ certificates
|
|||||||
dev/psql
|
dev/psql
|
||||||
|
|
||||||
.turbo
|
.turbo
|
||||||
packages/db/generated/client
|
packages/db/generated/client
|
||||||
|
*dist
|
||||||
43
apps/chat/Dockerfile
Normal file
43
apps/chat/Dockerfile
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
FROM node:lts-alpine AS base
|
||||||
|
|
||||||
|
FROM base AS builder
|
||||||
|
RUN apk update
|
||||||
|
RUN apk add --no-cache libc6-compat
|
||||||
|
WORKDIR /app
|
||||||
|
RUN yarn global add turbo@^2
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN turbo prune @hctv/chat --docker
|
||||||
|
|
||||||
|
FROM base AS installer
|
||||||
|
RUN apk update
|
||||||
|
RUN apk add --no-cache libc6-compat
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# First install the dependencies
|
||||||
|
COPY --from=builder /app/out/json/ .
|
||||||
|
RUN yarn install --frozen-lockfile
|
||||||
|
|
||||||
|
COPY --from=builder /app/out/full/ .
|
||||||
|
RUN --mount=type=secret,id=TURBO_TOKEN --mount=type=secret,id=TURBO_TEAM TURBO_TOKEN=$(cat /run/secrets/TURBO_TOKEN) TURBO_TEAM=$(cat /run/secrets/TURBO_TEAM) yarn turbo run build --filter=@hctv/chat
|
||||||
|
|
||||||
|
FROM base AS runner
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN apk add --no-cache curl
|
||||||
|
|
||||||
|
RUN addgroup --system --gid 1001 nodejs
|
||||||
|
RUN adduser --system --uid 1001 nodeapp
|
||||||
|
USER nodeapp
|
||||||
|
|
||||||
|
COPY --from=installer --chown=nodeapp:nodejs /app/apps/chat ./apps/chat
|
||||||
|
COPY --from=installer --chown=nodeapp:nodejs /app/node_modules ./node_modules
|
||||||
|
COPY --from=installer --chown=nodeapp:nodejs /app/package.json ./package.json
|
||||||
|
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
|
WORKDIR /app/apps/chat
|
||||||
|
|
||||||
|
EXPOSE 8000
|
||||||
|
|
||||||
|
ENTRYPOINT ["node", "dist/index.js"]
|
||||||
@@ -3,7 +3,8 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "tsx watch src/index.ts"
|
"dev": "tsx watch src/index.ts",
|
||||||
|
"build": "tsc --build"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hctv/auth": "*",
|
"@hctv/auth": "*",
|
||||||
@@ -16,6 +17,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^20.11.17",
|
"@types/node": "^20.11.17",
|
||||||
"tsx": "^4.7.1"
|
"tsx": "^4.7.1",
|
||||||
|
"typescript": "^5.8.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ app.get('/', async (c) => {
|
|||||||
return c.text(threed);
|
return c.text(threed);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.get('/up', async (c) => {
|
||||||
|
return c.text('it works');
|
||||||
|
});
|
||||||
|
|
||||||
app.get(
|
app.get(
|
||||||
'/ws/:username',
|
'/ws/:username',
|
||||||
upgradeWebSocket((c) => ({
|
upgradeWebSocket((c) => ({
|
||||||
|
|||||||
@@ -10,5 +10,7 @@
|
|||||||
],
|
],
|
||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
"jsxImportSource": "hono/jsx",
|
"jsxImportSource": "hono/jsx",
|
||||||
|
"outDir": "dist",
|
||||||
|
"rootDir": "src"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -29,7 +29,7 @@ const nextConfig = {
|
|||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
source: '/api/stream/chat/:path*',
|
source: '/api/stream/chat/:path*',
|
||||||
destination: `http://localhost:8000/:path*`,
|
destination: `http://${process.env.NODE_ENV === 'production' ? 'chat' : 'localhost'}:8000/:path*`,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import type { IncomingMessage } from 'http';
|
|||||||
import type { Server } from 'node:http';
|
import type { Server } from 'node:http';
|
||||||
import type { Http2SecureServer, Http2Server } from 'node:http2';
|
import type { Http2SecureServer, Http2Server } from 'node:http2';
|
||||||
import type { Duplex } from 'node:stream';
|
import type { Duplex } from 'node:stream';
|
||||||
|
import type { Buffer } from 'node:buffer';
|
||||||
import type { Channel, User } from '@hctv/db';
|
import type { Channel, User } from '@hctv/db';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -214,7 +215,7 @@ export declare class WSContext<T = unknown> {
|
|||||||
protocol: string | null;
|
protocol: string | null;
|
||||||
close(code?: number, reason?: string): void;
|
close(code?: number, reason?: string): void;
|
||||||
}
|
}
|
||||||
export type WSMessageReceive = string | Blob | ArrayBufferLike;
|
export type WSMessageReceive = string | Blob | ArrayBufferLike | Buffer;
|
||||||
export declare const createWSMessageEvent: (
|
export declare const createWSMessageEvent: (
|
||||||
source: WSMessageReceive
|
source: WSMessageReceive
|
||||||
) => MessageEvent<WSMessageReceive>;
|
) => MessageEvent<WSMessageReceive>;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"tasks": {
|
"tasks": {
|
||||||
"build": {
|
"build": {
|
||||||
"dependsOn": ["^db:generate", "prepare"],
|
"dependsOn": ["^db:generate", "prepare"],
|
||||||
"outputs": [".next/**", "!.next/cache/**"]
|
"outputs": [".next/**", "!.next/cache/**", "dist/**"]
|
||||||
},
|
},
|
||||||
"setup": {
|
"setup": {
|
||||||
"dependsOn": ["^dd", "^db:generate", "^build"],
|
"dependsOn": ["^dd", "^db:generate", "^build"],
|
||||||
|
|||||||
Reference in New Issue
Block a user