Skip to content

Commit

Permalink
增加dockerfile和docker-compose,修改当前进度。
Browse files Browse the repository at this point in the history
  • Loading branch information
jiayuqi7813 committed Dec 20, 2024
1 parent 715bf60 commit 994db2a
Show file tree
Hide file tree
Showing 10 changed files with 1,021 additions and 127 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ yarn-error.log*
.pnpm-debug.log*

# env files (can opt-in for committing if needed)
.env*
.env

# vercel
.vercel
Expand Down
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Use Node.js 14 as the base image
FROM node:22

# Set working directory
WORKDIR /app

# Copy package.json and package-lock.json
COPY package*.json ./

# Install dependencies
RUN npm install --force

# Copy all files
COPY . .

# Expose the port the app runs on
EXPOSE 3001

# Start the application
CMD ["npm", "start"]

1 change: 1 addition & 0 deletions app/room/[roomId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ export default async function Room({ params }: { params: Promise<{ roomId: strin
</main>
)
}

3 changes: 2 additions & 1 deletion components/CollaborativeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { io, Socket } from 'socket.io-client'
import MonacoEditor from '@monaco-editor/react'
import * as monaco from 'monaco-editor';

const BACKEND_URL = process.env.NEXT_PUBLIC_BACKEND_URL || 'http://localhost:3001'

interface CollaborativeEditorProps {
roomId: string | undefined
Expand All @@ -26,7 +27,7 @@ export default function CollaborativeEditor({ roomId }: CollaborativeEditorProps
return
}

socketRef.current = io()
socketRef.current = io(BACKEND_URL)

socketRef.current.on('connect', () => {
console.log('Connected to server')
Expand Down
18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: '3.8'

services:
backend:
build:
context: .
dockerfile: Dockerfile
ports:
- "3001:3001"
environment:
- NODE_ENV=production
- PORT=3001
- FRONTEND_URL=http://localhost:3000 # Update this for production
volumes:
- .:/app
- /app/node_modules
command: npm start

Loading

0 comments on commit 994db2a

Please sign in to comment.