Integrates docker.

This commit is contained in:
pa7ryk 2019-06-13 16:47:25 +02:00
parent 993b484396
commit f418dc26b8
5 changed files with 53 additions and 74 deletions

View file

@ -43,21 +43,15 @@ ShareDrop uses WebRTC only and isn't compatible with Safari browsers. Snapdrop u
* Do security analysis and suggestions
## Local Development
```
git clone git@github.com:RobinLinus/snapdrop.git
cd snapdrop/server
npm install
node index.js
[Install docker with docker-compose.](https://docs.docker.com/compose/install/)
# open a second shell:
cd snapdrop/client
# Python 2
python -m SimpleHTTPServer
# Python 3
python3 -m http.server
```
git clone git@github.com:pa7ryk/snapdrop.git
cd snapdrop
docker-compose up
```
Now point your browser to http://localhost:8000.
Now point your browser to http://localhost:8080.
   
## Deployment Notes
The client expects the server at http(s)://your.domain/server.

View file

@ -54,9 +54,8 @@ class ServerConnection {
_endpoint() {
// hack to detect if deployment or development environment
const protocol = location.protocol.startsWith('https') ? 'wss' : 'ws';
const host = location.hostname.startsWith('localhost') ? 'localhost:3000' : (location.host + '/server');
const webrtc = window.isRtcSupported ? '/webrtc' : '/fallback';
const url = protocol + '://' + host + webrtc;
const url = protocol + '://' + location.host + '/server' + webrtc;
return url;
}

16
docker-compose.yml Normal file
View file

@ -0,0 +1,16 @@
version: "3"
services:
node:
image: "node:lts-alpine"
user: "node"
working_dir: /home/node/app
volumes:
- ./server/:/home/node/app
command: ash -c "npm i && node index.js"
nginx:
image: "nginx:alpine"
volumes:
- ./client:/usr/share/nginx/html
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
ports:
- "8080:80"

View file

@ -1,60 +0,0 @@
# This is an configuration example. Please adjust to fit your environment (especially root location and server_name).
# The nginx user requires read permissions to the root location.
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
server_name your.domain;
root /path/to/snapdrop/client;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location /server {
proxy_pass http://localhost:3000/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $remote_addr;
}
location / {
proxy_http_version 1.1;
}
listen [::]:80 ;
listen 80 ;
}
}

30
nginx/default.conf Normal file
View file

@ -0,0 +1,30 @@
server {
listen 80;
#server_name your.domain;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /server {
proxy_connect_timeout 300;
proxy_pass http://node:3000;
proxy_set_header Connection "upgrade";
proxy_set_header Upgrade $http_upgrade;
proxy_set_header X-Forwarded-for $remote_addr;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}