Skip to content

Commit

Permalink
Update socket.ts and docker-compose.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
etienne committed Feb 7, 2024
1 parent de6534d commit 615cc23
Show file tree
Hide file tree
Showing 4 changed files with 4,503 additions and 9 deletions.
8 changes: 4 additions & 4 deletions backend/src/routes/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Server } from "socket.io";
import http from "http";
import { log } from "../utils/log.js";
import mongoose from "mongoose";
import { Room, Message } from "../models/models";
import { Room, Message } from "../models/models.js";
import express from "express";
import dotenv from "dotenv";

Expand All @@ -16,15 +16,15 @@ export const server = http.createServer(app);

const io = new Server(server, {
cors: {
origin: process.env.ORIGIN_URL,
methods: ["GET", "POST"],
origin: "*",
methods: ["GET", "POST", "PUT", "DELETE"],
},
maxHttpBufferSize: 2e7,
});

mongoose
.connect(
`mongodb://${process.env.MONGODB_USER}:${process.env.MONGODB_USER_PASSWORD}@localhost:27017/${process.env.MONGO_INITDB_DATABASE}`
`mongodb://${process.env.MONGODB_USER}:${process.env.MONGODB_USER_PASSWORD}@mongodb:27017/${process.env.MONGO_INITDB_DATABASE}`
)
.then(() => console.log("Connected to MongoDB"))
.catch((err: any) => console.error("Could not connect to MongoDB", err));
Expand Down
14 changes: 9 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ services:
- MONGODB_USER=${MONGODB_USER}
- MONGODB_USER_PASSWORD=${MONGODB_USER_PASSWORD}
volumes:
- ./backend/init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro
- ./init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro
networks:
- web

backend:
container_name: backend
image: node:21
working_dir: /backend/src/
command: sh -c "npm install && npm run dev:server"
command: sh -c "npm install && npm run start"
volumes:
- ./backend:/backend/src
networks:
Expand All @@ -53,16 +53,19 @@ services:
- MONGO_INITDB_DATABASE=${MONGO_INITDB_DATABASE}
- MONGODB_USER=${MONGODB_USER}
- MONGODB_USER_PASSWORD=${MONGODB_USER_PASSWORD}
- PORT=${PORT}
- DEBUG=${DEBUG}
- ORIGIN_URL=${ORIGIN_URL}
ports:
- 3333:3333
- 4000:4000

frontend:
container_name: frontend
depends_on:
- traefik
image: node:16
image: node:21
working_dir: /frontend/src
command: sh -c 'npm install && npm run start'
command: sh -c 'npm install && npm run dev'
volumes:
- ./frontend:/frontend/src
labels:
Expand All @@ -80,6 +83,7 @@ services:
- MONGODB_USER=${MONGODB_USER}
- MONGODB_USER_PASSWORD=${MONGODB_USER_PASSWORD}
- BROWSER=none
- NEXT_PUBLIC_BASE_URL=${NEXT_PUBLIC_BASE_URL}
ports:
- 3000:3000

Expand Down
Loading

0 comments on commit 615cc23

Please sign in to comment.