Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker containarized #137

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
npm-debug.log
2 changes: 2 additions & 0 deletions Dockerfile-ffmpeg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM jrottenberg/ffmpeg
#CMD "-f v4l2 -framerate 25 -video_size 640x480 -i /dev/video0 -f mpegts -codec:v mpeg1video -s 640x480 -b:v 1000k -bf 0 http://ws-relay:8081/sec"
6 changes: 6 additions & 0 deletions Dockerfile-http
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM node:latest
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY . /usr/src/app/
RUN npm install
CMD node node_modules/http-server/bin/http-server . -p 8090
6 changes: 6 additions & 0 deletions Dockerfile-ws
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM node:latest
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY . /usr/src/app/
RUN npm install
CMD node websocket-relay.js sec 8081 8082
28 changes: 28 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: '3'
services:
ffmpeg:
build:
context: .
dockerfile: Dockerfile-ffmpeg
depends_on:
- ws-relay
- http-server
links:
- ws-relay
entrypoint: ffmpeg
command: -f v4l2 -framerate 25 -video_size 640x480 -i /dev/video0 -f mpegts -codec:v mpeg1video -s 640x480 -b:v 1000k -bf 0 http://ws-relay:8081/sec
devices:
- "/dev/video0:/dev/video0"
http-server:
build:
context: .
dockerfile: Dockerfile-http
ports:
- "8090:8090"
ws-relay:
build:
context: .
dockerfile: Dockerfile-ws
ports:
- "8081:8081"
- "8082:8082"
22 changes: 22 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<title>JSMpeg Stream Client</title>
<style type="text/css">
html, body {
background-color: #111;
text-align: center;
}
</style>

</head>
<body>
<canvas id="video-canvas"></canvas>
<script type="text/javascript" src="jsmpeg.min.js"></script>
<script type="text/javascript">
var canvas = document.getElementById('video-canvas');
var url = 'ws://'+document.location.hostname+':8082/';
var player = new JSMpeg.Player(url, {canvas: canvas});
</script>
</body>
</html>
13 changes: 13 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "docker_web_app",
"version": "1.0.0",
"description": "Nodejs webserver on Docker",
"author": "Aus Rasul <[email protected]>",
"scripts": {
"start": "node server.js"
},
"dependencies": {
"http-server": "^0.9.0",
"ws": "^2.1.0"
}
}