Merge branch 'master' into sevey/health-check-additions
This commit is contained in:
commit
37b07c642b
|
@ -1,7 +1,23 @@
|
||||||
version: 2
|
version: 2
|
||||||
updates:
|
updates:
|
||||||
- package-ecosystem: npm
|
- package-ecosystem: npm
|
||||||
directory: "/"
|
directory: "/packages/handshake-api"
|
||||||
|
schedule:
|
||||||
|
interval: weekly
|
||||||
|
time: "10:00"
|
||||||
|
open-pull-requests-limit: 10
|
||||||
|
assignees:
|
||||||
|
- kwypchlo
|
||||||
|
- package-ecosystem: npm
|
||||||
|
directory: "/packages/health-check"
|
||||||
|
schedule:
|
||||||
|
interval: weekly
|
||||||
|
time: "10:00"
|
||||||
|
open-pull-requests-limit: 10
|
||||||
|
assignees:
|
||||||
|
- kwypchlo
|
||||||
|
- package-ecosystem: npm
|
||||||
|
directory: "/packages/webapp"
|
||||||
schedule:
|
schedule:
|
||||||
interval: weekly
|
interval: weekly
|
||||||
time: "10:00"
|
time: "10:00"
|
||||||
|
|
|
@ -11,18 +11,24 @@ jobs:
|
||||||
- name: Use Node.js
|
- name: Use Node.js
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
node-version: 12.x
|
node-version: 14.x
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn
|
run: yarn
|
||||||
|
|
||||||
- name: Static code analysis
|
- name: "Static code analysis: handshake-api"
|
||||||
run: yarn prettier --check .
|
run: yarn workspace handshake-api prettier --check .
|
||||||
|
|
||||||
- name: Build production bundle
|
- name: "Static code analysis: health-check"
|
||||||
run: yarn build
|
run: yarn workspace health-check prettier --check .
|
||||||
|
|
||||||
|
- name: "Static code analysis: webapp"
|
||||||
|
run: yarn workspace webapp prettier --check .
|
||||||
|
|
||||||
|
- name: "Build webapp"
|
||||||
|
run: yarn workspace webapp build
|
||||||
env:
|
env:
|
||||||
GATSBY_API_URL: "https://siasky.net"
|
GATSBY_API_URL: "https://siasky.dev"
|
||||||
|
|
||||||
- name: Cypress run
|
- name: Cypress run
|
||||||
uses: cypress-io/github-action@v1
|
uses: cypress-io/github-action@v1
|
||||||
|
@ -30,6 +36,7 @@ jobs:
|
||||||
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
|
working-directory: packages/webapp
|
||||||
record: true
|
record: true
|
||||||
start: npx http-server public --port 8000
|
start: npx http-server public --port 8000
|
||||||
wait-on: "http://localhost:8000"
|
wait-on: "http://localhost:8000"
|
||||||
|
|
|
@ -69,8 +69,8 @@ yarn-error.log
|
||||||
.yarn-integrity
|
.yarn-integrity
|
||||||
|
|
||||||
# Cypress
|
# Cypress
|
||||||
cypress/screenshots
|
packages/webapp/cypress/screenshots
|
||||||
cypress/videos
|
packages/webapp/cypress/videos
|
||||||
|
|
||||||
# Docker data
|
# Docker data
|
||||||
docker/data
|
docker/data
|
||||||
|
@ -78,3 +78,4 @@ docker/data
|
||||||
# Cache files
|
# Cache files
|
||||||
__pycache__
|
__pycache__
|
||||||
/.idea/
|
/.idea/
|
||||||
|
/venv/
|
||||||
|
|
|
@ -4,16 +4,41 @@ networks:
|
||||||
shared:
|
shared:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
webapp:
|
||||||
|
|
||||||
services:
|
services:
|
||||||
docker-host:
|
sia:
|
||||||
image: qoomon/docker-host
|
build:
|
||||||
container_name: docker-host
|
context: ./docker/sia
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
args:
|
||||||
|
branch: v1.5.0
|
||||||
|
container_name: sia
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
cap_add:
|
environment:
|
||||||
- NET_ADMIN
|
- SIA_MODULES=gctwr
|
||||||
- NET_RAW
|
env_file:
|
||||||
|
- .env
|
||||||
|
volumes:
|
||||||
|
- ./docker/data/sia:/sia-data
|
||||||
networks:
|
networks:
|
||||||
- shared
|
- shared
|
||||||
|
expose:
|
||||||
|
- 9980
|
||||||
|
|
||||||
|
sia-upload:
|
||||||
|
image: nebulouslabs/sia:alpine-1.5.0
|
||||||
|
container_name: sia-upload
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
- SIA_MODULES=gctwr
|
||||||
|
volumes:
|
||||||
|
- ./docker/data/sia-upload:/sia-data
|
||||||
|
networks:
|
||||||
|
- shared
|
||||||
|
expose:
|
||||||
|
- 9980
|
||||||
|
|
||||||
caddy:
|
caddy:
|
||||||
build:
|
build:
|
||||||
|
@ -33,13 +58,10 @@ services:
|
||||||
- "80:80"
|
- "80:80"
|
||||||
- "443:443"
|
- "443:443"
|
||||||
depends_on:
|
depends_on:
|
||||||
- docker-host
|
|
||||||
- nginx
|
- nginx
|
||||||
|
|
||||||
nginx:
|
nginx:
|
||||||
build:
|
image: openresty/openresty:1.15.8.3-2-xenial
|
||||||
context: .
|
|
||||||
dockerfile: ./docker/nginx/Dockerfile
|
|
||||||
container_name: nginx
|
container_name: nginx
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
env_file:
|
env_file:
|
||||||
|
@ -49,12 +71,25 @@ services:
|
||||||
- ./docker/nginx/conf.d:/etc/nginx/conf.d:ro
|
- ./docker/nginx/conf.d:/etc/nginx/conf.d:ro
|
||||||
- ./docker/data/nginx/cache:/data/nginx/cache
|
- ./docker/data/nginx/cache:/data/nginx/cache
|
||||||
- ./docker/data/nginx/logs:/usr/local/openresty/nginx/logs
|
- ./docker/data/nginx/logs:/usr/local/openresty/nginx/logs
|
||||||
|
- ./docker/data/sia/apipassword:/data/sia/apipassword:ro
|
||||||
|
- webapp:/var/www/webportal:ro
|
||||||
networks:
|
networks:
|
||||||
- shared
|
- shared
|
||||||
expose:
|
expose:
|
||||||
- 80
|
- 80
|
||||||
depends_on:
|
depends_on:
|
||||||
- docker-host
|
- sia
|
||||||
|
- handshake-api
|
||||||
|
|
||||||
|
webapp:
|
||||||
|
build:
|
||||||
|
context: ./packages/webapp
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
container_name: webapp
|
||||||
|
restart: unless-stopped
|
||||||
|
tty: true
|
||||||
|
volumes:
|
||||||
|
- webapp:/usr/app/public
|
||||||
|
|
||||||
handshake:
|
handshake:
|
||||||
build:
|
build:
|
||||||
|
@ -78,11 +113,12 @@ services:
|
||||||
|
|
||||||
handshake-api:
|
handshake-api:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: ./packages/handshake-api
|
||||||
dockerfile: ./docker/handshake-api/Dockerfile
|
dockerfile: Dockerfile
|
||||||
container_name: handshake-api
|
container_name: handshake-api
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
|
- HOSTNAME=0.0.0.0
|
||||||
- HSD_HOST=handshake
|
- HSD_HOST=handshake
|
||||||
- HSD_NETWORK=main
|
- HSD_NETWORK=main
|
||||||
- HSD_PORT=12037
|
- HSD_PORT=12037
|
||||||
|
@ -94,23 +130,23 @@ services:
|
||||||
- 3100
|
- 3100
|
||||||
depends_on:
|
depends_on:
|
||||||
- handshake
|
- handshake
|
||||||
- nginx
|
|
||||||
|
|
||||||
health-check:
|
health-check:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: ./packages/health-check
|
||||||
dockerfile: ./docker/health-check/Dockerfile
|
dockerfile: Dockerfile
|
||||||
container_name: health-check
|
container_name: health-check
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
volumes:
|
volumes:
|
||||||
- ./health-check:/usr/app/health-check
|
|
||||||
- ./docker/data/health-check/state:/usr/app/state
|
- ./docker/data/health-check/state:/usr/app/state
|
||||||
networks:
|
networks:
|
||||||
- shared
|
- shared
|
||||||
environment:
|
environment:
|
||||||
|
- HOSTNAME=0.0.0.0
|
||||||
- PORTAL_URL=nginx
|
- PORTAL_URL=nginx
|
||||||
expose:
|
expose:
|
||||||
- 3100
|
- 3100
|
||||||
depends_on:
|
depends_on:
|
||||||
- docker-host
|
- caddy
|
||||||
- nginx
|
- handshake
|
||||||
|
- handshake-api
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
FROM node:14.6.0
|
|
||||||
|
|
||||||
WORKDIR /usr/app
|
|
||||||
|
|
||||||
RUN yarn init -y && \
|
|
||||||
yarn add express express-http-proxy hs-client
|
|
||||||
|
|
||||||
COPY handshake-api/index.js ./
|
|
||||||
|
|
||||||
ENV HOST="localhost"
|
|
||||||
ENV PORT=3100
|
|
||||||
|
|
||||||
ENV HSD_NETWORK="main"
|
|
||||||
ENV HSD_HOST="0.0.0.0"
|
|
||||||
ENV HSD_PORT=12037
|
|
||||||
ENV HSD_API_KEY="foo"
|
|
||||||
|
|
||||||
EXPOSE $PORT
|
|
||||||
|
|
||||||
ENTRYPOINT ["node", "index.js"]
|
|
|
@ -1,9 +1,10 @@
|
||||||
FROM node:14.6.0
|
# we can't use alpine image since it fails on node-gyp
|
||||||
|
FROM node:14.8.0
|
||||||
|
|
||||||
WORKDIR /opt/hsd
|
WORKDIR /opt/hsd
|
||||||
|
|
||||||
RUN git clone https://github.com/handshake-org/hsd.git /opt/hsd && \
|
RUN git clone https://github.com/handshake-org/hsd.git /opt/hsd
|
||||||
npm install --production
|
RUN npm install --production
|
||||||
|
|
||||||
ENV PATH="${PATH}:/opt/hsd/bin:/opt/hsd/node_modules/.bin"
|
ENV PATH="${PATH}:/opt/hsd/bin:/opt/hsd/node_modules/.bin"
|
||||||
|
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
FROM node:14.6.0
|
|
||||||
|
|
||||||
WORKDIR /usr/app
|
|
||||||
|
|
||||||
RUN yarn init -y
|
|
||||||
RUN yarn add express body-parser lowdb node-schedule superagent lodash http-status-codes
|
|
||||||
|
|
||||||
EXPOSE 3100
|
|
||||||
|
|
||||||
ENV NODE_ENV production
|
|
||||||
CMD [ "node", "health-check/index.js" ]
|
|
|
@ -1,15 +0,0 @@
|
||||||
FROM node:14.6.0 AS webportal-builder
|
|
||||||
|
|
||||||
COPY src ./src
|
|
||||||
COPY static ./static
|
|
||||||
COPY gatsby-config.js .
|
|
||||||
COPY package.json .
|
|
||||||
COPY yarn.lock .
|
|
||||||
|
|
||||||
ENV CYPRESS_INSTALL_BINARY 0
|
|
||||||
RUN yarn --frozen-lockfile
|
|
||||||
RUN yarn build
|
|
||||||
|
|
||||||
FROM openresty/openresty:1.15.8.3-2-xenial
|
|
||||||
|
|
||||||
COPY --from=webportal-builder /public /var/www/webportal
|
|
|
@ -13,12 +13,8 @@ set_real_ip_from 172.16.0.0/12;
|
||||||
set_real_ip_from 192.168.0.0/16;
|
set_real_ip_from 192.168.0.0/16;
|
||||||
real_ip_header X-Forwarded-For;
|
real_ip_header X-Forwarded-For;
|
||||||
|
|
||||||
upstream siad-upload {
|
|
||||||
server docker-host:9970;
|
|
||||||
}
|
|
||||||
|
|
||||||
upstream siad {
|
upstream siad {
|
||||||
server docker-host:9980;
|
server sia:9980;
|
||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
|
@ -96,6 +92,9 @@ server {
|
||||||
proxy_pass http://siad/skynet/stats;
|
proxy_pass http://siad/skynet/stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# This endpoint is a backward compatilibilty workaround for reporting stats from legacy
|
||||||
|
# upload siad node for portals that used double-siad setup. If your portal does not need
|
||||||
|
# to support additional siad node, you can remove it from this config.
|
||||||
location /statsdown {
|
location /statsdown {
|
||||||
include /etc/nginx/conf.d/include/cors;
|
include /etc/nginx/conf.d/include/cors;
|
||||||
|
|
||||||
|
@ -103,7 +102,7 @@ server {
|
||||||
proxy_cache_valid any 10m; # cache stats for 10 minutes
|
proxy_cache_valid any 10m; # cache stats for 10 minutes
|
||||||
proxy_set_header User-Agent: Sia-Agent;
|
proxy_set_header User-Agent: Sia-Agent;
|
||||||
proxy_read_timeout 5m; # extend the read timeout
|
proxy_read_timeout 5m; # extend the read timeout
|
||||||
proxy_pass http://siad-upload/skynet/stats; # serve upload node stats temporarily
|
proxy_pass http://sia-upload:9980/skynet/stats; # serve upload node stats temporarily
|
||||||
}
|
}
|
||||||
|
|
||||||
location /health-check {
|
location /health-check {
|
||||||
|
@ -114,6 +113,7 @@ server {
|
||||||
|
|
||||||
location /hns {
|
location /hns {
|
||||||
include /etc/nginx/conf.d/include/cors;
|
include /etc/nginx/conf.d/include/cors;
|
||||||
|
include /etc/nginx/conf.d/include/proxy-buffer;
|
||||||
|
|
||||||
proxy_pass http://handshake-api:3100;
|
proxy_pass http://handshake-api:3100;
|
||||||
}
|
}
|
||||||
|
@ -173,8 +173,10 @@ server {
|
||||||
|
|
||||||
location ~ "^/([a-zA-Z0-9-_]{46}(/.*)?)$" {
|
location ~ "^/([a-zA-Z0-9-_]{46}(/.*)?)$" {
|
||||||
include /etc/nginx/conf.d/include/cors;
|
include /etc/nginx/conf.d/include/cors;
|
||||||
|
include /etc/nginx/conf.d/include/proxy-buffer;
|
||||||
|
|
||||||
limit_conn downloads_by_ip 100; # ddos protection: max 100 downloads at a time
|
limit_conn downloads_by_ip 100; # ddos protection: max 100 downloads at a time
|
||||||
|
add_header Cache-Control "public, max-age=86400"; # allow consumer to cache response
|
||||||
|
|
||||||
# we need to explicitly use set directive here because $1 will contain the skylink with
|
# we need to explicitly use set directive here because $1 will contain the skylink with
|
||||||
# decoded whitespaces and set will re-encode it for us before passing it to proxy_pass
|
# decoded whitespaces and set will re-encode it for us before passing it to proxy_pass
|
||||||
|
@ -185,22 +187,21 @@ server {
|
||||||
# proxy this call to siad /skynet/skylink/ endpoint (make sure the ip is correct)
|
# proxy this call to siad /skynet/skylink/ endpoint (make sure the ip is correct)
|
||||||
proxy_pass http://siad/skynet/skylink/$skylink$is_args$args;
|
proxy_pass http://siad/skynet/skylink/$skylink$is_args$args;
|
||||||
|
|
||||||
# if you are expecting large headers (ie. Skynet-Skyfile-Metadata), tune these values to your needs
|
|
||||||
proxy_buffer_size 128k;
|
|
||||||
proxy_buffers 4 128k;
|
|
||||||
|
|
||||||
# cache frequent (> 10) downloads for 24 hours
|
# cache frequent (> 10) downloads for 24 hours
|
||||||
proxy_cache skynet;
|
proxy_cache skynet;
|
||||||
proxy_cache_key $uri;
|
proxy_cache_key $uri;
|
||||||
proxy_cache_min_uses 10;
|
proxy_cache_min_uses 10;
|
||||||
proxy_cache_valid 200 1440m;
|
proxy_cache_valid 200 1440m;
|
||||||
proxy_cache_bypass $cookie_nocache $arg_nocache; # add cache bypass option
|
proxy_cache_bypass $cookie_nocache $arg_nocache; # add cache bypass option
|
||||||
|
add_header X-Proxy-Cache $upstream_cache_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
location ~ "^/file/([a-zA-Z0-9-_]{46}(/.*)?)$" {
|
location ~ "^/file/([a-zA-Z0-9-_]{46}(/.*)?)$" {
|
||||||
include /etc/nginx/conf.d/include/cors;
|
include /etc/nginx/conf.d/include/cors;
|
||||||
|
include /etc/nginx/conf.d/include/proxy-buffer;
|
||||||
|
|
||||||
limit_conn downloads_by_ip 100; # ddos protection: max 100 downloads at a time
|
limit_conn downloads_by_ip 100; # ddos protection: max 100 downloads at a time
|
||||||
|
add_header Cache-Control "public, max-age=86400"; # allow consumer to cache response
|
||||||
|
|
||||||
# we need to explicitly use set directive here because $1 will contain the skylink with
|
# we need to explicitly use set directive here because $1 will contain the skylink with
|
||||||
# decoded whitespaces and set will re-encode it for us before passing it to proxy_pass
|
# decoded whitespaces and set will re-encode it for us before passing it to proxy_pass
|
||||||
|
@ -212,15 +213,12 @@ server {
|
||||||
# this alias also adds attachment=true url param to force download the file
|
# this alias also adds attachment=true url param to force download the file
|
||||||
proxy_pass http://siad/skynet/skylink/$skylink?attachment=true&$args;
|
proxy_pass http://siad/skynet/skylink/$skylink?attachment=true&$args;
|
||||||
|
|
||||||
# if you are expecting large headers (ie. Skynet-Skyfile-Metadata), tune these values to your needs
|
|
||||||
proxy_buffer_size 128k;
|
|
||||||
proxy_buffers 4 128k;
|
|
||||||
|
|
||||||
# cache frequent (> 10) downloads for 24 hours
|
# cache frequent (> 10) downloads for 24 hours
|
||||||
proxy_cache skynet;
|
proxy_cache skynet;
|
||||||
proxy_cache_key $uri;
|
proxy_cache_key $uri;
|
||||||
proxy_cache_min_uses 10;
|
proxy_cache_min_uses 10;
|
||||||
proxy_cache_valid 200 1440m;
|
proxy_cache_valid 200 1440m;
|
||||||
proxy_cache_bypass $cookie_nocache $arg_nocache; # add cache bypass option
|
proxy_cache_bypass $cookie_nocache $arg_nocache; # add cache bypass option
|
||||||
|
add_header X-Proxy-Cache $upstream_cache_status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
more_set_headers 'Access-Control-Allow-Origin: *';
|
|
||||||
more_set_headers 'Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE';
|
|
||||||
more_set_headers 'Access-Control-Allow-Headers: DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
|
|
||||||
more_set_headers 'Access-Control-Expose-Headers: Content-Length,Content-Range';
|
|
|
@ -1,9 +1,14 @@
|
||||||
if ($request_method = 'OPTIONS') {
|
if ($request_method = 'OPTIONS') {
|
||||||
add_header 'Access-Control-Allow-Origin' '*';
|
more_set_headers 'Access-Control-Allow-Origin: *';
|
||||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
more_set_headers 'Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE';
|
||||||
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
|
more_set_headers 'Access-Control-Allow-Headers: DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
|
||||||
add_header 'Access-Control-Max-Age' 1728000; # valid for 20 days
|
more_set_headers 'Access-Control-Max-Age: 1728000';
|
||||||
add_header 'Content-Type' 'text/plain; charset=utf-8';
|
more_set_headers 'Content-Type: text/plain; charset=utf-8';
|
||||||
add_header 'Content-Length' 0;
|
more_set_headers 'Content-Length: 0';
|
||||||
return 204;
|
return 204;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
more_set_headers 'Access-Control-Allow-Origin: *';
|
||||||
|
more_set_headers 'Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE';
|
||||||
|
more_set_headers 'Access-Control-Allow-Headers: DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
|
||||||
|
more_set_headers 'Access-Control-Expose-Headers: Content-Length,Content-Range,Skynet-File-Metadata';
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
# if you are expecting large headers (ie. Skynet-Skyfile-Metadata), tune these values to your needs
|
||||||
|
proxy_buffer_size 128k;
|
||||||
|
proxy_buffers 4 256k;
|
||||||
|
proxy_busy_buffers_size 256k;
|
|
@ -1,10 +1,15 @@
|
||||||
rewrite_by_lua_block {
|
rewrite_by_lua_block {
|
||||||
-- local b64 = require("ngx.base64")
|
local b64 = require("ngx.base64")
|
||||||
-- pull apipassword from SIA_API_AUTHORIZATION environment variable
|
-- open apipassword file for reading (b flag is required for some reason)
|
||||||
-- local apipassword = os.getenv("SIA_API_AUTHORIZATION")
|
-- (file /etc/.sia/apipassword has to be mounted from the host system)
|
||||||
|
local apipassword_file = io.open("/data/sia/apipassword", "rb")
|
||||||
|
-- read apipassword file contents and trim newline (important)
|
||||||
|
local apipassword = apipassword_file:read("*all"):gsub("%s+", "")
|
||||||
|
-- make sure to close file after reading the password
|
||||||
|
apipassword_file.close()
|
||||||
-- encode the user:password authorization string
|
-- encode the user:password authorization string
|
||||||
-- (in our case user is empty so it is just :password)
|
-- (in our case user is empty so it is just :password)
|
||||||
-- local content = b64.encode_base64url(":" .. apipassword)
|
local content = b64.encode_base64url(":" .. apipassword)
|
||||||
-- set authorization header with proper base64 encoded string
|
-- set authorization header with proper base64 encoded string
|
||||||
ngx.req.set_header("Authorization", "Basic " .. os.getenv("SIA_API_AUTHORIZATION"))
|
ngx.req.set_header("Authorization", "Basic " .. content)
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,10 +16,7 @@
|
||||||
# See https://github.com/openresty/docker-openresty/blob/master/README.md#nginx-config-files
|
# See https://github.com/openresty/docker-openresty/blob/master/README.md#nginx-config-files
|
||||||
#
|
#
|
||||||
|
|
||||||
# expose environment variables
|
user root;
|
||||||
env SIA_API_AUTHORIZATION;
|
|
||||||
|
|
||||||
#user nobody;
|
|
||||||
worker_processes 1;
|
worker_processes 1;
|
||||||
|
|
||||||
#error_log logs/error.log;
|
#error_log logs/error.log;
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
FROM golang AS sia-builder
|
||||||
|
|
||||||
|
ENV GOOS linux
|
||||||
|
ENV GOARCH amd64
|
||||||
|
|
||||||
|
ARG branch=master
|
||||||
|
|
||||||
|
RUN git clone https://gitlab.com/NebulousLabs/Sia.git --single-branch --branch ${branch}
|
||||||
|
RUN make release --directory Sia
|
||||||
|
|
||||||
|
FROM nebulouslabs/sia:alpine-1.5.0
|
||||||
|
|
||||||
|
COPY --from=sia-builder /go/bin/siac /go/bin/siad /usr/bin/
|
88
package.json
88
package.json
|
@ -1,86 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "skynet-webportal",
|
"private": true,
|
||||||
"description": "Sia Skynet",
|
"workspaces": [
|
||||||
"version": "1.0.0",
|
"packages/*"
|
||||||
"author": "Nebulous",
|
]
|
||||||
"dependencies": {
|
|
||||||
"axios": "^0.19.2",
|
|
||||||
"bytes": "^3.1.0",
|
|
||||||
"classnames": "^2.2.6",
|
|
||||||
"gatsby": "^2.24.5",
|
|
||||||
"gatsby-image": "^2.4.13",
|
|
||||||
"gatsby-plugin-manifest": "^2.4.18",
|
|
||||||
"gatsby-plugin-matomo": "^0.8.3",
|
|
||||||
"gatsby-plugin-react-helmet": "^3.3.10",
|
|
||||||
"gatsby-plugin-remove-serviceworker": "^1.0.0",
|
|
||||||
"gatsby-plugin-robots-txt": "^1.5.1",
|
|
||||||
"gatsby-plugin-sass": "^2.3.12",
|
|
||||||
"gatsby-plugin-sharp": "^2.6.20",
|
|
||||||
"gatsby-source-filesystem": "^2.3.20",
|
|
||||||
"gatsby-transformer-sharp": "^2.5.11",
|
|
||||||
"http-status-codes": "^1.4.0",
|
|
||||||
"jsonp": "^0.2.1",
|
|
||||||
"node-sass": "^4.14.0",
|
|
||||||
"path-browserify": "^1.0.1",
|
|
||||||
"prop-types": "^15.7.2",
|
|
||||||
"react": "^16.13.1",
|
|
||||||
"react-countup": "^4.3.3",
|
|
||||||
"react-dom": "^16.13.1",
|
|
||||||
"react-dropzone": "^11.0.2",
|
|
||||||
"react-helmet": "^6.1.0",
|
|
||||||
"react-mailchimp-form": "^1.0.2",
|
|
||||||
"react-mailchimp-subscribe": "^2.1.0",
|
|
||||||
"react-reveal": "^1.2.2",
|
|
||||||
"react-syntax-highlighter": "^12.2.1",
|
|
||||||
"react-visibility-sensor": "^5.1.1",
|
|
||||||
"skynet-js": "0.0.8",
|
|
||||||
"typeface-metropolis": "^0.0.74"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"cypress": "^4.10.0",
|
|
||||||
"cypress-file-upload": "^4.0.7",
|
|
||||||
"eslint": "^7.5.0",
|
|
||||||
"eslint-config-prettier": "^6.11.0",
|
|
||||||
"eslint-plugin-cypress": "^2.11.1",
|
|
||||||
"eslint-plugin-react": "^7.20.3",
|
|
||||||
"husky": "^4.2.5",
|
|
||||||
"lint-staged": "^10.2.11",
|
|
||||||
"prettier": "^2.0.5"
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"sia",
|
|
||||||
"skynet",
|
|
||||||
"nebulous",
|
|
||||||
"blockchain",
|
|
||||||
"decentralized",
|
|
||||||
"cloud storage"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"scripts": {
|
|
||||||
"build": "gatsby build",
|
|
||||||
"start": "gatsby develop",
|
|
||||||
"serve": "gatsby serve",
|
|
||||||
"clean": "gatsby clean"
|
|
||||||
},
|
|
||||||
"husky": {
|
|
||||||
"hooks": {
|
|
||||||
"pre-commit": "lint-staged"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"lint-staged": {
|
|
||||||
"*.{js,jsx,ts,tsx}": [
|
|
||||||
"eslint --fix",
|
|
||||||
"prettier --write"
|
|
||||||
],
|
|
||||||
"*.{md,html,css,scss}": [
|
|
||||||
"prettier --write"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/NebulousLabs/skynet-webportal"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/NebulousLabs/skynet-webportal/issues"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
/package.json
|
|
@ -0,0 +1,16 @@
|
||||||
|
FROM node:14.8.0-alpine
|
||||||
|
|
||||||
|
WORKDIR /usr/app
|
||||||
|
|
||||||
|
COPY package.json .
|
||||||
|
RUN yarn --no-lockfile
|
||||||
|
COPY src/* src/
|
||||||
|
|
||||||
|
ENV HSD_NETWORK="main"
|
||||||
|
ENV HSD_HOST="0.0.0.0"
|
||||||
|
ENV HSD_PORT=12037
|
||||||
|
ENV HSD_API_KEY="foo"
|
||||||
|
|
||||||
|
EXPOSE 3100
|
||||||
|
ENV NODE_ENV production
|
||||||
|
CMD [ "node", "--max-http-header-size=64000", "src/index.js" ]
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"name": "handshake-api",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"main": "index.js",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"express": "^4.17.1",
|
||||||
|
"express-http-proxy": "^1.6.2",
|
||||||
|
"hs-client": "^0.0.9"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"prettier": "^2.0.5"
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,7 +19,8 @@ const clientOptions = {
|
||||||
};
|
};
|
||||||
const client = new NodeClient(clientOptions);
|
const client = new NodeClient(clientOptions);
|
||||||
|
|
||||||
const startsWithSkylinkRegExp = /^[a-zA-Z0-9_-]{46}/;
|
// Match both `sia://HASH` and `HASH` links.
|
||||||
|
const startsWithSkylinkRegExp = /^(sia:\/\/)?[a-zA-Z0-9_-]{46}/;
|
||||||
|
|
||||||
const getDomainRecords = async (name) => {
|
const getDomainRecords = async (name) => {
|
||||||
const response = await client.execute("getnameresource", [name]);
|
const response = await client.execute("getnameresource", [name]);
|
||||||
|
@ -31,7 +32,13 @@ const getDomainRecords = async (name) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const findSkylinkRecord = (records) => {
|
const findSkylinkRecord = (records) => {
|
||||||
return records?.find(({ txt }) => txt?.some((entry) => isValidSkylink(entry)));
|
// Find the last one, so people can update their domains in a non-destructive
|
||||||
|
// way by simply adding a new link. This will also allow keeping links to
|
||||||
|
// older versions for backwards compatibility.
|
||||||
|
return records
|
||||||
|
?.slice()
|
||||||
|
.reverse()
|
||||||
|
.find(({ txt }) => txt?.some((entry) => isValidSkylink(entry)));
|
||||||
};
|
};
|
||||||
|
|
||||||
const getSkylinkFromRecord = (record) => {
|
const getSkylinkFromRecord = (record) => {
|
||||||
|
@ -69,7 +76,10 @@ server.use(
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
userResHeaderDecorator(headers, userReq, userRes, proxyReq, proxyRes) {
|
userResHeaderDecorator(headers, userReq, userRes, proxyReq, proxyRes) {
|
||||||
if (headers.location && headers.location.match(startsWithSkylinkRegExp)) {
|
if (headers.location && headers.location.match(startsWithSkylinkRegExp)) {
|
||||||
headers.location = headers.location.replace(startsWithSkylinkRegExp, `/hns/${userReq.params.name}`);
|
headers.location = headers.location.replace(
|
||||||
|
startsWithSkylinkRegExp,
|
||||||
|
`/hns/${userReq.params.name.replace("sia://", "")}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return headers;
|
return headers;
|
||||||
|
@ -81,18 +91,16 @@ server.use(
|
||||||
const record = findSkylinkRecord(records);
|
const record = findSkylinkRecord(records);
|
||||||
if (!record) throw new Error(`No skylink found in dns records of ${req.params.name}`);
|
if (!record) throw new Error(`No skylink found in dns records of ${req.params.name}`);
|
||||||
|
|
||||||
const skylink = getSkylinkFromRecord(record);
|
const skylink = getSkylinkFromRecord(record).replace("sia://", ""); // get skylink and strip sia:// prefix
|
||||||
const basepath = url.resolve("/", skylink); // make the url absolute
|
const basepath = url.resolve("/", skylink); // make the url absolute
|
||||||
const subpath = req.url.slice(1); // drop the leading slash
|
const subpath = req.url.slice(1); // drop the leading slash
|
||||||
|
|
||||||
// if the skylink from handshake does not contain a subpath but subpath
|
// if the record is just a raw skylink, replace baseUrl with /skylink
|
||||||
// is defined in request, join the skylink and subpath together (do not
|
if (skylink.length === 46) {
|
||||||
// use url.resolve because it will replace skylink with subapth thinking
|
return req.originalUrl.replace(req.baseUrl, basepath);
|
||||||
// it is relative)
|
|
||||||
if (skylink.length === 46 && subpath) {
|
|
||||||
return `${basepath}/${subpath}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if the record contains more than a skylink then it needs to be resolved
|
||||||
return url.resolve(basepath, subpath);
|
return url.resolve(basepath, subpath);
|
||||||
},
|
},
|
||||||
})
|
})
|
|
@ -0,0 +1 @@
|
||||||
|
/package.json
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"printWidth": 120
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
FROM node:14.8.0-alpine
|
||||||
|
|
||||||
|
WORKDIR /usr/app
|
||||||
|
|
||||||
|
COPY package.json .
|
||||||
|
RUN yarn --no-lockfile
|
||||||
|
COPY src/* src/
|
||||||
|
|
||||||
|
EXPOSE 3100
|
||||||
|
ENV NODE_ENV production
|
||||||
|
CMD [ "node", "src/index.js" ]
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"name": "health-check",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"main": "index.js",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"body-parser": "^1.19.0",
|
||||||
|
"express": "^4.17.1",
|
||||||
|
"http-status-codes": "^1.4.0",
|
||||||
|
"lodash": "^4.17.19",
|
||||||
|
"lowdb": "^1.0.0",
|
||||||
|
"node-schedule": "^1.3.2",
|
||||||
|
"superagent": "^6.0.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"prettier": "^2.0.5"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"printWidth": 120
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
FROM node:14.8.0-alpine
|
||||||
|
|
||||||
|
WORKDIR /usr/app
|
||||||
|
|
||||||
|
COPY src ./src
|
||||||
|
COPY static ./static
|
||||||
|
COPY gatsby-config.js .
|
||||||
|
COPY package.json .
|
||||||
|
|
||||||
|
ENV CYPRESS_INSTALL_BINARY 0
|
||||||
|
ENV GATSBY_TELEMETRY_DISABLED 1
|
||||||
|
RUN yarn --no-lockfile
|
||||||
|
RUN yarn build
|
|
@ -19,7 +19,7 @@ context("Skynet", () => {
|
||||||
|
|
||||||
cy.get('.home-upload input[type="file"]').attachFile(fileName);
|
cy.get('.home-upload input[type="file"]').attachFile(fileName);
|
||||||
|
|
||||||
cy.get(".home-uploaded-files").children().should("have.length", 1);
|
cy.get(".home-uploaded-files").children().should("have.length", 1).scrollIntoView();
|
||||||
|
|
||||||
// wait max 2 minutes, the portal might be slow at times
|
// wait max 2 minutes, the portal might be slow at times
|
||||||
cy.wait("@upload", { responseTimeout: 2 * 60 * 1000 });
|
cy.wait("@upload", { responseTimeout: 2 * 60 * 1000 });
|
|
@ -0,0 +1,86 @@
|
||||||
|
{
|
||||||
|
"name": "webapp",
|
||||||
|
"description": "Sia Skynet",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"author": "Nebulous",
|
||||||
|
"dependencies": {
|
||||||
|
"axios": "^0.19.2",
|
||||||
|
"bytes": "^3.1.0",
|
||||||
|
"classnames": "^2.2.6",
|
||||||
|
"gatsby": "^2.24.47",
|
||||||
|
"gatsby-image": "^2.4.16",
|
||||||
|
"gatsby-plugin-manifest": "^2.4.23",
|
||||||
|
"gatsby-plugin-matomo": "^0.8.3",
|
||||||
|
"gatsby-plugin-react-helmet": "^3.3.10",
|
||||||
|
"gatsby-plugin-remove-serviceworker": "^1.0.0",
|
||||||
|
"gatsby-plugin-robots-txt": "^1.5.1",
|
||||||
|
"gatsby-plugin-sass": "^2.3.12",
|
||||||
|
"gatsby-plugin-sharp": "^2.6.27",
|
||||||
|
"gatsby-source-filesystem": "^2.3.24",
|
||||||
|
"gatsby-transformer-sharp": "^2.5.13",
|
||||||
|
"http-status-codes": "^1.4.0",
|
||||||
|
"jsonp": "^0.2.1",
|
||||||
|
"node-sass": "^4.14.0",
|
||||||
|
"path-browserify": "^1.0.1",
|
||||||
|
"prop-types": "^15.7.2",
|
||||||
|
"react": "^16.13.1",
|
||||||
|
"react-countup": "^4.3.3",
|
||||||
|
"react-dom": "^16.13.1",
|
||||||
|
"react-dropzone": "^11.0.2",
|
||||||
|
"react-helmet": "^6.1.0",
|
||||||
|
"react-mailchimp-form": "^1.0.2",
|
||||||
|
"react-mailchimp-subscribe": "^2.1.0",
|
||||||
|
"react-reveal": "^1.2.2",
|
||||||
|
"react-syntax-highlighter": "^13.5.0",
|
||||||
|
"react-visibility-sensor": "^5.1.1",
|
||||||
|
"skynet-js": "0.0.8",
|
||||||
|
"typeface-metropolis": "^0.0.74"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"cypress": "^4.10.0",
|
||||||
|
"cypress-file-upload": "^4.0.7",
|
||||||
|
"eslint": "^7.7.0",
|
||||||
|
"eslint-config-prettier": "^6.11.0",
|
||||||
|
"eslint-plugin-cypress": "^2.11.1",
|
||||||
|
"eslint-plugin-react": "^7.20.6",
|
||||||
|
"husky": "^4.2.5",
|
||||||
|
"lint-staged": "^10.2.11",
|
||||||
|
"prettier": "^2.0.5"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"sia",
|
||||||
|
"skynet",
|
||||||
|
"nebulous",
|
||||||
|
"blockchain",
|
||||||
|
"decentralized",
|
||||||
|
"cloud storage"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"scripts": {
|
||||||
|
"build": "gatsby build",
|
||||||
|
"start": "gatsby develop",
|
||||||
|
"serve": "gatsby serve",
|
||||||
|
"clean": "gatsby clean"
|
||||||
|
},
|
||||||
|
"husky": {
|
||||||
|
"hooks": {
|
||||||
|
"pre-commit": "lint-staged"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"lint-staged": {
|
||||||
|
"*.{js,jsx,ts,tsx}": [
|
||||||
|
"eslint --fix",
|
||||||
|
"prettier --write"
|
||||||
|
],
|
||||||
|
"*.{md,html,css,scss}": [
|
||||||
|
"prettier --write"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/NebulousLabs/skynet-webportal"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/NebulousLabs/skynet-webportal/issues"
|
||||||
|
}
|
||||||
|
}
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue