Skip to content

Commit 2838af0

Browse files
committed
Add Dockerfile to Comms module
Unsuccessful attempt to tunnel the socketio into the backend. Current proposed solution is to expose the backend comms service on a port.
1 parent b87bac3 commit 2838af0

File tree

6 files changed

+52
-4
lines changed

6 files changed

+52
-4
lines changed

comms/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM node:lts-alpine3.20
2+
3+
WORKDIR /comms
4+
COPY package*.json ./
5+
RUN npm install --force
6+
COPY . .
7+
EXPOSE 4001
8+
CMD ["npm", "run", "dev"]

comms/server.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ const server = http.createServer(app);
55
const io = require("socket.io")(server, {
66
cors: {
77
// temporarily use * to allow all origins
8-
origin: `*`,
9-
methods: [ "GET", "POST" ]
8+
origin: `*`
109
}
1110
});
1211

compose.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,19 @@ services:
135135
path: collab
136136
target: collab/app
137137

138+
comms:
139+
build: comms
140+
image: wzwren/comms
141+
env_file:
142+
- comms/.env
143+
ports:
144+
- "4001:4001"
145+
develop:
146+
watch:
147+
- action: sync
148+
path: comms
149+
target: /comms
150+
138151
nginx:
139152
build: nginx
140153
image: distractedcat/nginx

nginx/nginx.conf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ http {
4444
server collab:4000;
4545
}
4646

47+
# upstream comms {
48+
# server comms:4001;
49+
# }
50+
4751
server {
4852
listen 80;
4953
location / {
@@ -85,5 +89,27 @@ http {
8589
proxy_set_header Connection "upgrade";
8690
proxy_read_timeout 86400;
8791
}
92+
93+
# location /comms/ {
94+
# proxy_pass http://comms/;
95+
# proxy_set_header Host $host;
96+
# proxy_set_header X-Real-IP $remote_addr;
97+
# proxy_set_header X-Forwarded-Proto $scheme;
98+
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
99+
# proxy_http_version 1.1;
100+
# proxy_read_timeout 86400;
101+
# }
102+
103+
# location /socket.io/ {
104+
# proxy_pass http://comms/socket.io/;
105+
# proxy_set_header Host $host;
106+
# proxy_set_header X-Real-IP $remote_addr;
107+
# proxy_set_header X-Forwarded-Proto $scheme;
108+
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
109+
# proxy_http_version 1.1;
110+
# proxy_set_header Upgrade $http_upgrade;
111+
# proxy_set_header Connection "upgrade";
112+
# proxy_read_timeout 86400;
113+
# }
88114
}
89115
}

peerprep/components/questionpage/CommsPanel.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface Props {
77
roomId?: String;
88
}
99

10-
const socket = io("http://localhost:4001");
10+
const socket = io(`${process.env.NEXT_PUBLIC_COMMS}`);
1111

1212
function CommsPanel({ className, roomId }: Props) {
1313
const [stream, setStream] = useState<MediaStream>();
@@ -61,6 +61,8 @@ function CommsPanel({ className, roomId }: Props) {
6161

6262
useEffect(() => {
6363
if (!roomId || !stream || !socket.connected) {
64+
console.log("stream status: " + stream);
65+
console.log("connection status: " + socket.connected);
6466
return;
6567
}
6668
console.log("in hook");

peerprep/next.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = {
1010
// by default we expect NEXT_PUBLIC_COLLAB to be http://collab:4000.
1111
// double check this before using this.
1212
destination: `${process.env.NEXT_PUBLIC_NGINX}/${process.env.NEXT_PUBLIC_COLLAB}/ws`,
13-
},
13+
}
1414
];
1515
},
1616
};

0 commit comments

Comments
 (0)