First attempt at a netlify deploy preview
This commit is contained in:
parent
91ee615aee
commit
2279e555a3
80
.netlify/build-deploy-preview.sh
Normal file
80
.netlify/build-deploy-preview.sh
Normal file
@ -0,0 +1,80 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Set directory to location of this script
|
||||
# https://stackoverflow.com/a/3355423/1867984
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
# Helpful to verify which versions we're using
|
||||
yarn -v
|
||||
node -v
|
||||
|
||||
# Install GitBook CLI
|
||||
echo 'Installing Gitbook CLI'
|
||||
yarn global add gitbook-cli
|
||||
|
||||
echo 'Running Gitbook installation'
|
||||
# Generate all version's GitBook output
|
||||
# For each directory in /docs ...
|
||||
cd ./../docs/
|
||||
for D in *; do
|
||||
if [ -d "${D}" ]; then
|
||||
|
||||
echo "Generating output for: ${D}"
|
||||
cd "${D}"
|
||||
|
||||
# Clear previous output, generate new
|
||||
rm -rf _book
|
||||
gitbook install
|
||||
gitbook build
|
||||
|
||||
cd ..
|
||||
|
||||
fi
|
||||
done
|
||||
|
||||
# Move CNAME File into `latest`
|
||||
cp CNAME ./latest/_book/CNAME
|
||||
|
||||
# Create a history folder in our latest version's output
|
||||
mkdir ./latest/_book/history
|
||||
|
||||
# Move each version's files to latest's history folder
|
||||
for D in *; do
|
||||
# If it's a directory
|
||||
if [ -d "${D}" ]; then
|
||||
# If the directory name starts with `v` (v1, v2, etc.)
|
||||
if [ "${D}" == v* ] ; then
|
||||
|
||||
echo "Moving ${D} to the latest version's history folder"
|
||||
|
||||
mkdir "./latest/_book/history/${D}"
|
||||
cp -v -r "./${D}/_book"/* "./latest/_book/history/${D}"
|
||||
|
||||
fi
|
||||
fi
|
||||
done
|
||||
cd ..
|
||||
|
||||
# Build and copy the PWA Viewer into the demo directory
|
||||
mkdir ./docs/latest/_book/demo/
|
||||
|
||||
# Install build deps and all monorepo package dependencies. Yarn Workspaces
|
||||
# should also symlink all projects appropriately
|
||||
yarn install
|
||||
|
||||
# Navigate to our Viewer project
|
||||
cd ./platform/viewer/
|
||||
|
||||
# Create a Versions File
|
||||
node -p -e \"'export default \\'' + require('./package.json').version + '\\';'\" > src/version.js
|
||||
# Copy over wado-image-loader codecs and worker file
|
||||
npx cpx \"node_modules/cornerstone-wado-image-loader/dist/*.min.js*\" \"public\" -v
|
||||
# Build using react-scripts
|
||||
# npx cross-env PUBLIC_URL=/demo REACT_APP_CONFIG=config/netlify.js react-scripts --max_old_space_size=4096 build
|
||||
# Build using WebPack
|
||||
# TODO: consume public/config correctly instead of hardcode
|
||||
npx cross-env NODE_ENV=production webpack-dev-server --config config/webpack.prod.js --mode production -w -d
|
||||
# Copy output to the folder that is our publish target
|
||||
npx cpx 'dist/**/*' ./../../docs/latest/_book/demo --verbose
|
||||
|
||||
echo 'Nothing left to see here. Go home, folks.'
|
||||
@ -1,8 +0,0 @@
|
||||
{
|
||||
"trailingComma": "es5",
|
||||
"printWidth": 80,
|
||||
"proseWrap": "always",
|
||||
"tabWidth": 2,
|
||||
"semi": true,
|
||||
"singleQuote": true
|
||||
}
|
||||
18
README.md
18
README.md
@ -1,5 +1,8 @@
|
||||
# OHIF Medical Imaging Platform
|
||||
|
||||
[![lerna][lerna-image]][lerna-url]
|
||||
[![Netlify Status][netlify-image]][netlify-url]
|
||||
|
||||
## The Problem
|
||||
|
||||
...
|
||||
@ -54,12 +57,12 @@ more about it in our [Architecture Documentation](#todo).
|
||||
### Getting Started
|
||||
|
||||
1. [Fork this repository][how-to-fork]
|
||||
1. [Clone your forked repository][how-to-clone]
|
||||
2. [Clone your forked repository][how-to-clone]
|
||||
- `git clone https://github.com/YOUR-USERNAME/Viewers.git`
|
||||
1. Navigate to the cloned project's directory
|
||||
1. Add this repo as a `remote` named `upstream`
|
||||
3. Navigate to the cloned project's directory
|
||||
4. Add this repo as a `remote` named `upstream`
|
||||
- `git remote add upstream https://github.com/OHIF/Viewers.git`
|
||||
1. `yarn install` to restore dependencies and link projects
|
||||
5. `yarn install` to restore dependencies and link projects
|
||||
|
||||
#### To Develop
|
||||
|
||||
@ -109,7 +112,12 @@ PWA builds go through
|
||||
-->
|
||||
|
||||
<!-- prettier-ignore-start -->
|
||||
|
||||
<!-- Badges -->
|
||||
[lerna-image]: https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg
|
||||
[lerna-url]: https://lerna.js.org/
|
||||
[netlify-image]: https://api.netlify.com/api/v1/badges/a5d369ab-18a6-41c3-bcde-83805205ac7f/deploy-status
|
||||
[netlify-url]: https://app.netlify.com/sites/ohif/deploys
|
||||
<!-- Links -->
|
||||
[monorepo]: https://en.wikipedia.org/wiki/Monorepo
|
||||
[how-to-fork]: https://help.github.com/en/articles/fork-a-repo
|
||||
[how-to-clone]: https://help.github.com/en/articles/fork-a-repo#step-2-create-a-local-clone-of-your-fork
|
||||
|
||||
23
docs/latest/advanced/monorepos-a-crash-courese.md
Normal file
23
docs/latest/advanced/monorepos-a-crash-courese.md
Normal file
@ -0,0 +1,23 @@
|
||||
# MonoRepos: A Crash Course
|
||||
|
||||
- [Lerna][lerna]
|
||||
|
||||
Solutions:
|
||||
|
||||
## Semantic-Release
|
||||
|
||||
- [Semantic-Release](https://github.com/semantic-release/semantic-release/issues/193#issuecomment-462063871)
|
||||
- [Multi-semantic-release](https://github.com/dhoulb/multi-semantic-release)
|
||||
- [semantic-release-monorepo](https://github.com/Updater/semantic-release-monorepo)
|
||||
|
||||
# Netlify
|
||||
|
||||
- https://community.netlify.com/t/best-practices-for-deploying-sites-from-monorepos/818
|
||||
|
||||
<!--
|
||||
Links
|
||||
-->
|
||||
|
||||
<!-- prettier-ignore-start -->
|
||||
[lerna]: https://github.com/lerna/lerna
|
||||
<!-- prettier-ignore-end -->
|
||||
70
netlify.toml
Normal file
70
netlify.toml
Normal file
@ -0,0 +1,70 @@
|
||||
# Netlify Config
|
||||
#
|
||||
# TOML Reference:
|
||||
# https://www.netlify.com/docs/netlify-toml-reference/
|
||||
#
|
||||
|
||||
# Settings in the [build] context are global and are applied to all contexts
|
||||
# unless otherwise overridden by more specific contexts.
|
||||
[build]
|
||||
# Directory to change to before starting a build.
|
||||
# This is where we will look for package.json/.nvmrc/etc.
|
||||
base = ""
|
||||
publish = "project/build-output/"
|
||||
|
||||
|
||||
# NODE_VERSION in root `.nvmrc` takes priority
|
||||
# YARN_FLAGS: https://www.netlify.com/docs/build-gotchas/#yarn
|
||||
[build.environment]
|
||||
NODE_VERSION = "10.16.0"
|
||||
YARN_VERSION = "1.17.3"
|
||||
YARN_FLAGS = "--no-ignore-optional --pure-lockfile"
|
||||
|
||||
|
||||
# Production context: all deploys from the Production branch set in your site's
|
||||
# deploy contexts will inherit these settings.
|
||||
# [context.production]
|
||||
# publish = "project/output/"
|
||||
# command = "make publish"
|
||||
# environment = { ACCESS_TOKEN = "super secret", NODE_VERSION = "8.0.1" }
|
||||
|
||||
# Deploy Preview context: all deploys generated from a pull/merge request will
|
||||
# inherit these settings.
|
||||
[context.deploy-preview]
|
||||
base = ""
|
||||
publish = "docs/latest/_book/"
|
||||
command = ".netlify/build-deploy-preview.sh"
|
||||
|
||||
# Redirects and headers are GLOBAL for all builds – they do not get scoped to
|
||||
# contexts no matter where you define them in the file.
|
||||
# For context-specific rules, use _headers or _redirects files, which are
|
||||
# PER-DEPLOY.
|
||||
# The following redirect is intended for use with most SPAs that handle
|
||||
# routing internally.
|
||||
# By default, redirects won't be applied if there's a file with the same
|
||||
# path as the one defined in the `from` property. Setting `force` to `true`
|
||||
# will make the redirect rule take precedence over any existing files.
|
||||
[[redirects]]
|
||||
from = "/*"
|
||||
to = "/index.html"
|
||||
status = 200
|
||||
|
||||
[[redirects]]
|
||||
from = "/demo/*"
|
||||
to = "/demo/index.html"
|
||||
status = 200
|
||||
|
||||
[[headers]]
|
||||
# Define which paths this specific [[headers]] block will cover.
|
||||
for = "/*"
|
||||
|
||||
[headers.values]
|
||||
X-Frame-Options = "DENY"
|
||||
X-XSS-Protection = "1; mode=block"
|
||||
|
||||
# Multi-key header rules are expressed with multi-line strings.
|
||||
cache-control = '''
|
||||
max-age=0,
|
||||
no-cache,
|
||||
no-store,
|
||||
must-revalidate'''
|
||||
@ -1,18 +1,16 @@
|
||||
const merge = require('webpack-merge');
|
||||
const path = require('path');
|
||||
const merge = require("webpack-merge");
|
||||
const path = require("path");
|
||||
const workboxPlugin = require("workbox-webpack-plugin");
|
||||
const common = require("./webpack.common");
|
||||
|
||||
const workboxPlugin = require('workbox-webpack-plugin');
|
||||
|
||||
const common = require('./webpack.common');
|
||||
|
||||
const SRC_DIR = path.join(__dirname, '../src');
|
||||
const DIST_DIR = path.join(__dirname, '../dist');
|
||||
const SRC_DIR = path.join(__dirname, "../src");
|
||||
const DIST_DIR = path.join(__dirname, "../dist");
|
||||
|
||||
module.exports = (env, argv) => {
|
||||
const commonConfig = common(env, argv);
|
||||
|
||||
return merge(commonConfig, {
|
||||
mode: 'production',
|
||||
mode: "production",
|
||||
stats: {
|
||||
colors: false,
|
||||
hash: true,
|
||||
@ -22,15 +20,15 @@ module.exports = (env, argv) => {
|
||||
chunkModules: true,
|
||||
modules: true,
|
||||
children: true,
|
||||
warnings: true,
|
||||
warnings: true
|
||||
},
|
||||
optimization: {
|
||||
minimize: true,
|
||||
sideEffects: true,
|
||||
sideEffects: true
|
||||
},
|
||||
output: {
|
||||
path: DIST_DIR,
|
||||
filename: '[name].bundle.[chunkhash].js',
|
||||
filename: "[name].bundle.[chunkhash].js"
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
@ -38,32 +36,32 @@ module.exports = (env, argv) => {
|
||||
test: /\.(gif|jpe?g|png|svg)$/i,
|
||||
use: [
|
||||
{
|
||||
loader: 'url-loader',
|
||||
loader: "url-loader",
|
||||
options: {
|
||||
limit: 8192,
|
||||
},
|
||||
},
|
||||
],
|
||||
limit: 8192
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
test: /\.(ttf|eot|woff|woff2)$/i,
|
||||
use: [
|
||||
{
|
||||
loader: 'url-loader',
|
||||
loader: "url-loader",
|
||||
options: {
|
||||
limit: 50000,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
limit: 50000
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new workboxPlugin.GenerateSW({
|
||||
swDest: 'sw.js',
|
||||
swDest: "sw.js",
|
||||
clientsClaim: true,
|
||||
skipWaiting: true,
|
||||
}),
|
||||
],
|
||||
skipWaiting: true
|
||||
})
|
||||
]
|
||||
});
|
||||
};
|
||||
|
||||
@ -1,57 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Set directory to location of this script
|
||||
# https://stackoverflow.com/a/3355423/1867984
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
yarn -v
|
||||
node -v
|
||||
echo 'Installing Gitbook CLI'
|
||||
yarn global add gitbook-cli
|
||||
|
||||
echo 'Running Gitbook installation'
|
||||
|
||||
# Generate all version's GitBook output
|
||||
# For each directory in /docs ...
|
||||
cd ./docs/
|
||||
for D in *; do
|
||||
if [ -d "${D}" ]; then
|
||||
|
||||
echo "Generating output for: ${D}"
|
||||
cd "${D}"
|
||||
|
||||
# Clear previous output, generate new
|
||||
rm -rf _book
|
||||
gitbook install
|
||||
gitbook build
|
||||
|
||||
cd ..
|
||||
|
||||
fi
|
||||
done
|
||||
|
||||
# Move CNAME File into `latest`
|
||||
cp CNAME ./latest/_book/CNAME
|
||||
|
||||
# Create a history folder in our latest version's output
|
||||
mkdir ./latest/_book/history
|
||||
|
||||
# Move each version's files to latest's history folder
|
||||
for D in *; do
|
||||
if [ -d "${D}" ]; then
|
||||
if [ "${D}" == v* ] ; then
|
||||
|
||||
echo "Moving ${D} to the latest version's history folder"
|
||||
|
||||
mkdir "./latest/_book/history/${D}"
|
||||
cp -v -r "./${D}/_book"/* "./latest/_book/history/${D}"
|
||||
|
||||
fi
|
||||
fi
|
||||
done
|
||||
cd ..
|
||||
|
||||
# Build and copy the StandaloneViewer into the static directory
|
||||
mkdir ./docs/latest/_book/demo/
|
||||
yarn install
|
||||
yarn build:web:ci
|
||||
@ -1,25 +0,0 @@
|
||||
# https://www.netlify.com/docs/netlify-toml-reference/
|
||||
|
||||
[build]
|
||||
# Directory (relative to root of your repo) that contains the deploy-ready
|
||||
# HTML files and assets generated by the build. If a base directory has
|
||||
# been specified, include it in the publish directory path.
|
||||
publish = "docs/latest/_book/"
|
||||
|
||||
# COMMENT: NODE_VERSION in root `.nvmrc` takes priority
|
||||
# COMMENT: Why we specify YARN_FLAGS: https://www.netlify.com/docs/build-gotchas/#yarn
|
||||
[build.environment]
|
||||
NODE_VERSION = "10.15.3"
|
||||
YARN_VERSION = "1.15.2"
|
||||
YARN_FLAGS = "--no-ignore-optional --pure-lockfile"
|
||||
|
||||
# COMMENT: This a rule for Single Page Applications
|
||||
[[redirects]]
|
||||
from = "/demo/*"
|
||||
to = "/demo/index.html"
|
||||
status = 200
|
||||
|
||||
[[redirects]]
|
||||
from = "/*"
|
||||
to = "/index.html"
|
||||
status = 200
|
||||
@ -20,15 +20,11 @@
|
||||
"build:package": "yarn run preBuild && node --max-old-space-size=4096 node_modules/rollup/bin/rollup -c",
|
||||
"build:package:ci": "yarn run preBuild && node --max-old-space-size=4096 node_modules/rollup/bin/rollup -c",
|
||||
"build:web": "yarn run preBuild && react-scripts --max_old_space_size=4096 build",
|
||||
"build:web:ci": "yarn run preBuild && cross-env PUBLIC_URL=/demo REACT_APP_CONFIG=config/netlify.js react-scripts --max_old_space_size=4096 build && cpx 'build/**/*' docs/latest/_book/demo --verbose",
|
||||
"build:demo:ci": "yarn run preBuild && cross-env PUBLIC_URL=/ REACT_APP_CONFIG=config/demo.js react-scripts --max_old_space_size=4096 build",
|
||||
"lint": "eslint -c .eslintrc --fix src && prettier --single-quote --write src/**/*.{js,jsx,json,css}",
|
||||
"test:unit": "jest",
|
||||
"test:unit:ci": "jest --ci --runInBand --collectCoverage --reporters=default --reporters=jest-junit && codecov",
|
||||
"test:e2e": "",
|
||||
"test:e2e:ci": "start-server-and-test start http://localhost:5000 cy:run:ci",
|
||||
"staticDeploy": "./generateStaticSite.sh",
|
||||
"docs:publish": "./publishStaticSite.sh",
|
||||
"start": "yarn run dev",
|
||||
"predeploy": "cd example && npm install && yarn run build:package",
|
||||
"preBuild": "yarn run version && yarn run copy:webworkers",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user