From 2b817d2e28a88c1768a22b2ec07561a5155f6813 Mon Sep 17 00:00:00 2001 From: aza Date: Tue, 23 Jan 2018 06:26:27 -0300 Subject: [PATCH] Docker to build the web wallet and serve it. (#1033) --- Dockerfile | 27 +++++++++++++++++++++ README.md | 5 +++- conf/nginx.conf | 58 ++++++++++++++++++++++++++++++++++++++++++++++ conf/start.sh | 8 +++++++ docker-compose.yml | 12 ++++++++++ 5 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100644 conf/nginx.conf create mode 100644 conf/start.sh create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..d3b7406243 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM node:6 + +# Install nginx +RUN apt-get update \ + && apt-get install -y nginx --no-install-recommends \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +RUN npm install -g cross-env + +# We copy the code from the docker-compose-yml +# RUN git clone https://github.com/bitshares/bitshares-ui.git /bitshares-ui +CMD mkdir /bitshares-ui +WORKDIR /bitshares-ui + +ADD package.json . +RUN cross-env npm install --env.prod + +EXPOSE 80 + +## Copying default configuration +ADD conf/nginx.conf /etc/nginx/nginx.conf +ADD conf/start.sh /start.sh +RUN chmod a+x /start.sh + +## Entry point +ENTRYPOINT ["/start.sh"] diff --git a/README.md b/README.md index 69e773581f..3948b64114 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,10 @@ __Mac__ This will compile the UI with some special modifications for use with Electron, generate installable binaries with Electron and copy the result to the root `build/binaries` folder. +### Docker + +Clone this repository, run `docker-compose up` and visit localhost:8080 + ## Contributing Please work off the staging branch and make pull requests to that branch. The master branch will only be updated for new releases. @@ -115,4 +119,3 @@ Our style guideline is based on 'Airbnb JavaScript Style Guide' (https://github. - Spaces inside curly braces are optional We strongly encourage to use _eslint_ to make sure the code adhere to our style guidelines. - diff --git a/conf/nginx.conf b/conf/nginx.conf new file mode 100644 index 0000000000..efbdaf855d --- /dev/null +++ b/conf/nginx.conf @@ -0,0 +1,58 @@ + +worker_processes 4; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + sendfile on; + + keepalive_timeout 165; + + gzip on; + gzip_disable "msie6"; + gzip_comp_level 6; + gzip_min_length 1100; + gzip_buffers 16 8k; + gzip_proxied any; + gzip_types + text/plain + text/css + text/js + text/xml + text/javascript + application/javascript + application/x-javascript + application/json + application/xml + application/rss+xml + image/svg+xml; + + server { + listen 80; + server_name _; + root /var/www/; + + ssl off; + # @TODO configure ssl + + location ~ ^/(img|images|photo|photos|page|pages|uploads|countries|make|pic|foto|list|pictures|news|feed|rotated|carimg|category|reviews) { + access_log off; + return 404; + } + + # This makes the faucet work + location ~ ^/[\w\d\.-]+\.(js|css|dat|png|json|ico)$ { + try_files $uri $uri/wallet =404; + } + + location / { + index index.html index.htm; + try_files $uri /index.html; + } + } +} diff --git a/conf/start.sh b/conf/start.sh new file mode 100644 index 0000000000..2552fea6a3 --- /dev/null +++ b/conf/start.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# We build the wallet each time we run the docker and it takes a couple of minutes +npm run build + +cp -r /bitshares-ui/build/dist/* /var/www/ + +nginx -g "daemon off;" diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000..aac4fca421 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: "2" +volumes: + wallet_build: {} + +services: + web-wallet: + build: . + ports: + - "8080:80" + volumes: + - wallet_build:/bitshares-ui/build/dist + - .:/bitshares-ui