diff --git a/.gitignore b/.gitignore index 884a06b7..289498d4 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ cabal.sandbox.config *.chi *.chs.h *.lksh* +bundle/ diff --git a/.travis.yml b/.travis.yml index f6039a30..a309ea98 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,15 +30,12 @@ notifications: email: true before_deploy: - - mkdir bundle - - cp `stack path --dist-dir`/build/trypurescript/trypurescript bundle/ - - cp LICENSE bundle/ - - tar czf trypurescript.tar.gz -C bundle/ . + ./ci/before_deploy.sh deploy: provider: releases api_key: $RELEASE_KEY - file: trypurescript.tar.gz + file: trypurescript-$COMPONENT.tar.gz skip_cleanup: true on: tags: true diff --git a/README.md b/README.md index 2077296f..6bd843ef 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ npm install npm run build npm run bundle +cd public httpserver 8080 #eg with: alias httpserver='python -m SimpleHTTPServer' open http://localhost:8080 ``` diff --git a/ci/before_deploy.sh b/ci/before_deploy.sh new file mode 100644 index 00000000..52cfbf97 --- /dev/null +++ b/ci/before_deploy.sh @@ -0,0 +1,24 @@ +#! /usr/bin/env bash + +set -ex + +case $COMPONENT in + server) + mkdir bundle + cp $(stack path --dist-dir)/build/trypurescript/trypurescript bundle/ + cp LICENSE bundle/ + cp -r deploy/ bundle/ + cp -r staging/ bundle/ + tar czf trypurescript-server.tar.gz -C bundle/ . + ;; + client) + mkdir bundle + cp LICENSE bundle/ + cp -r client/public/ bundle/ + tar czf trypurescript-client.tar.gz -C bundle/ . + ;; + *) + echo >&2 "Unrecognised component: $COMPONENT" + exit 1 + ;; +esac diff --git a/client/.gitignore b/client/.gitignore index 370786a3..d4779c13 100644 --- a/client/.gitignore +++ b/client/.gitignore @@ -6,5 +6,5 @@ /.purs* /.psa* /.stack* -/js/index.js +/public/js/index.js .spago/ diff --git a/client/CNAME b/client/CNAME deleted file mode 100644 index d238d507..00000000 --- a/client/CNAME +++ /dev/null @@ -1 +0,0 @@ -try.purescript.org diff --git a/client/LICENSE b/client/LICENSE deleted file mode 100644 index 91038416..00000000 --- a/client/LICENSE +++ /dev/null @@ -1,12 +0,0 @@ -Copyright (c) 2013-16 PureScript -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/client/package.json b/client/package.json index f8708fed..bdcbe669 100644 --- a/client/package.json +++ b/client/package.json @@ -3,7 +3,7 @@ "scripts": { "clean": "rimraf output", "build": "spago build --purs-args '--censor-lib --strict'", - "bundle": "spago bundle-app --to js/index.js" + "bundle": "spago bundle-app --to public/js/index.js" }, "devDependencies": { "purescript": "^0.13.6", diff --git a/client/css/flare.css b/client/public/css/flare.css similarity index 100% rename from client/css/flare.css rename to client/public/css/flare.css diff --git a/client/css/index.css b/client/public/css/index.css similarity index 100% rename from client/css/index.css rename to client/public/css/index.css diff --git a/client/css/mathbox.css b/client/public/css/mathbox.css similarity index 100% rename from client/css/mathbox.css rename to client/public/css/mathbox.css diff --git a/client/css/slides.css b/client/public/css/slides.css similarity index 100% rename from client/css/slides.css rename to client/public/css/slides.css diff --git a/client/css/style.css b/client/public/css/style.css similarity index 100% rename from client/css/style.css rename to client/public/css/style.css diff --git a/client/frame.html b/client/public/frame.html similarity index 100% rename from client/frame.html rename to client/public/frame.html diff --git a/client/img/favicon-white.svg b/client/public/img/favicon-white.svg similarity index 100% rename from client/img/favicon-white.svg rename to client/public/img/favicon-white.svg diff --git a/client/img/favicon_clear-16.png b/client/public/img/favicon_clear-16.png similarity index 100% rename from client/img/favicon_clear-16.png rename to client/public/img/favicon_clear-16.png diff --git a/client/img/favicon_clear-256.png b/client/public/img/favicon_clear-256.png similarity index 100% rename from client/img/favicon_clear-256.png rename to client/public/img/favicon_clear-256.png diff --git a/client/img/favicon_clear-32.png b/client/public/img/favicon_clear-32.png similarity index 100% rename from client/img/favicon_clear-32.png rename to client/public/img/favicon_clear-32.png diff --git a/client/img/loading.gif b/client/public/img/loading.gif similarity index 100% rename from client/img/loading.gif rename to client/public/img/loading.gif diff --git a/client/index.html b/client/public/index.html similarity index 100% rename from client/index.html rename to client/public/index.html diff --git a/client/js/frame.js b/client/public/js/frame.js similarity index 100% rename from client/js/frame.js rename to client/public/js/frame.js diff --git a/deploy/nginx.conf b/deploy/nginx.conf new file mode 100644 index 00000000..0186c3d4 --- /dev/null +++ b/deploy/nginx.conf @@ -0,0 +1,78 @@ + +server { + listen 80 default_server; + listen [::]:80 default_server; + + return 301 https://$host$request_uri; +} + +server { + server_name try.purescript.org; + + listen 443 ssl http2; + listen [::]:443 ssl http2; + + # SSL configuration + # based on https://ssl-config.mozilla.org/ + ssl_certificate /etc/letsencrypt/live/try.purescript.org/fullchain.pem; + ssl_trusted_certificate /etc/letsencrypt/live/try.purescript.org/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/try.purescript.org/privkey.pem; + ssl_session_timeout 1d; + ssl_session_cache shared:ssl:10m; + ssl_session_tickets off; + ssl_stapling on; + ssl_stapling_verify on; + ssl_dhparam /etc/nginx/ssl_dhparam; + ssl_protocols TLSv1.2 TLSv1.3; + ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384; + ssl_prefer_server_ciphers off; + + # HSTS + # Maybe enable this later + # Low max-age to start with, just in case + # add_header Strict-Transport-Security "max-age=60" always; + + # + # try.purescript.org specific things + # + + location / { + root /var/www/trypurescript/public; + } + +} + +server { + server_name compile.purescript.org; + + listen 443 ssl http2; + listen [::]:443 ssl http2; + + # SSL configuration + # based on https://ssl-config.mozilla.org/ + ssl_certificate /etc/letsencrypt/live/try.purescript.org/fullchain.pem; + ssl_trusted_certificate /etc/letsencrypt/live/try.purescript.org/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/try.purescript.org/privkey.pem; + ssl_session_timeout 1d; + ssl_session_cache shared:ssl:10m; + ssl_session_tickets off; + ssl_stapling on; + ssl_stapling_verify on; + ssl_dhparam /etc/nginx/ssl_dhparam; + ssl_protocols TLSv1.2 TLSv1.3; + ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384; + ssl_prefer_server_ciphers off; + + # HSTS + # Maybe enable this later + # Low max-age to start with, just in case + # add_header Strict-Transport-Security "max-age=60" always; + + # + # compile.purescript.org specific things + # + + location / { + proxy_pass http://127.0.0.1:8081; + } +} diff --git a/deploy/start b/deploy/start new file mode 100644 index 00000000..6b8f3861 --- /dev/null +++ b/deploy/start @@ -0,0 +1,3 @@ +#! /usr/bin/env/bash + +exec trypurescript +RTS -N1 -A128m -M750M -RTS 8081 $(spago sources) diff --git a/deploy/trypurescript.service b/deploy/trypurescript.service new file mode 100644 index 00000000..cc4ba004 --- /dev/null +++ b/deploy/trypurescript.service @@ -0,0 +1,13 @@ +[Unit] +Description=Web service for Try PureScript + +[Service] +Type=simple +User=www-data +ExecStart=/var/www/trypurescript/deploy/start +WorkingDirectory=/var/www/trypurescript/staging +Restart=always +RestartSec=5s + +[Install] +WantedBy=multi-user.target