diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b763d82 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +node_modules +dist +Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c39effd --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +# Frontend build environment +FROM node:10.5-alpine + +RUN mkdir -p /usr/src/app + +COPY package.json /usr/src/app +RUN cd /usr/src/app && npm install + +COPY . /usr/src/app +RUN cd /usr/src/app && npm run build + +# Final nginx container +FROM nginx:1.15 + +COPY nginx/default.conf /etc/nginx/conf.d +COPY --from=0 /usr/src/app/dist/ /usr/share/nginx/html/ diff --git a/nginx/default.conf b/nginx/default.conf new file mode 100644 index 0000000..e247ba2 --- /dev/null +++ b/nginx/default.conf @@ -0,0 +1,29 @@ +server { + listen 80; + server_name streaming; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + } + + location = /janus { proxy_pass http://janus:8088/janus; } + location /janus/ { proxy_pass http://janus:8088/janus/; } + location /janus-ws { + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + proxy_pass http://janus:8188; + } + + location /socket.io { + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + proxy_pass http://api:5000/socket.io; + } + + location /api { + proxy_pass http://api:5000/api; + } +} diff --git a/src/components/SceneView.vue b/src/components/SceneView.vue index 5bf9272..c45ab07 100644 --- a/src/components/SceneView.vue +++ b/src/components/SceneView.vue @@ -4,7 +4,7 @@ - @@ -44,6 +44,12 @@ export default { }, currentScene () { return this.$store.state.scenes[this.$route.params.id] + }, + janusConfig () { + var wsproto = (window.location.protocol === 'https:') ? 'wss' : 'ws' + return { + url: `${wsproto}://${window.location.host}/janus-ws` + } } } } diff --git a/src/store.js b/src/store.js index c3eaace..666ba47 100644 --- a/src/store.js +++ b/src/store.js @@ -32,7 +32,7 @@ export default new Vuex.Store({ }, actions: { initialize ({ commit }) { - this.socket = io('http://' + API_HOST + ':5000') + this.socket = io() this.socket.on('connect', () => { console.log('Socket.IO connected:', this.socket.id)