2019-04-30 05:49:29 +02:00
|
|
|
# Build for Production
|
|
|
|
|
|
2019-12-07 06:12:08 +01:00
|
|
|
> If you've already followed the
|
|
|
|
|
> ["Getting Started" Guide](/development/getting-started.md), you can skip ahead
|
|
|
|
|
> to [Configuration](#configuration)
|
2019-04-30 05:49:29 +02:00
|
|
|
|
2019-04-30 16:39:24 +02:00
|
|
|
## Overview
|
2019-04-30 05:49:29 +02:00
|
|
|
|
|
|
|
|
### Build Machine Requirements
|
|
|
|
|
|
|
|
|
|
- [Node.js & NPM](https://nodejs.org/en/download/)
|
|
|
|
|
- [Yarn](https://yarnpkg.com/lang/en/docs/install/)
|
|
|
|
|
- [Git](https://www.atlassian.com/git/tutorials/install-git)
|
|
|
|
|
|
2019-04-30 15:52:51 +02:00
|
|
|
### Getting the Code
|
2019-04-30 05:49:29 +02:00
|
|
|
|
|
|
|
|
_With Git:_
|
|
|
|
|
|
2019-04-30 15:52:51 +02:00
|
|
|
```bash
|
2019-04-30 05:49:29 +02:00
|
|
|
# Clone the remote repository to your local machine
|
|
|
|
|
git clone https://github.com/OHIF/Viewers.git
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
More on: _[`git clone`](https://git-scm.com/docs/git-clone),
|
|
|
|
|
[`git checkout`](https://git-scm.com/docs/git-checkout)_
|
|
|
|
|
|
|
|
|
|
_From .zip:_
|
|
|
|
|
|
2019-09-06 16:27:02 +02:00
|
|
|
[OHIF/Viewers: react.zip](https://github.com/OHIF/Viewers/archive/master.zip)
|
2019-04-30 05:49:29 +02:00
|
|
|
|
2019-04-30 15:52:51 +02:00
|
|
|
### Restore Dependencies & Build
|
2019-04-30 05:49:29 +02:00
|
|
|
|
2019-04-30 17:56:13 +02:00
|
|
|
Open your terminal, and navigate to the directory containing the source files.
|
|
|
|
|
Next run these commands:
|
2019-04-30 05:49:29 +02:00
|
|
|
|
2019-04-30 15:52:51 +02:00
|
|
|
```js
|
2019-09-06 16:27:02 +02:00
|
|
|
// If you haven't already, enable yarn workspaces
|
|
|
|
|
yarn config set workspaces-experimental true
|
|
|
|
|
|
2019-04-30 15:52:51 +02:00
|
|
|
// Restore dependencies
|
|
|
|
|
yarn install
|
2019-04-30 05:49:29 +02:00
|
|
|
|
2019-04-30 15:52:51 +02:00
|
|
|
// Build source code for production
|
2019-09-06 16:27:02 +02:00
|
|
|
yarn run build
|
2019-04-30 15:52:51 +02:00
|
|
|
```
|
2019-04-30 05:49:29 +02:00
|
|
|
|
2019-09-06 16:27:02 +02:00
|
|
|
If everything worked as expected, you should have a new `dist/` directory in the
|
|
|
|
|
project's folder. It should roughly resemble the following:
|
2019-04-30 15:52:51 +02:00
|
|
|
|
|
|
|
|
```bash
|
2019-10-15 14:56:54 +02:00
|
|
|
<root>platform/viewer/dist/
|
2019-09-06 16:27:02 +02:00
|
|
|
├── app-config.js
|
|
|
|
|
├── app.bundle.js
|
|
|
|
|
├── app.css
|
2019-04-30 15:52:51 +02:00
|
|
|
├── index.html
|
|
|
|
|
├── manifest.json
|
|
|
|
|
├── service-worker.js
|
|
|
|
|
└── ...
|
|
|
|
|
```
|
2019-04-30 05:49:29 +02:00
|
|
|
|
2019-04-30 16:39:24 +02:00
|
|
|
By default, the build output will connect to OHIF's publicly accessible PACS. If
|
|
|
|
|
this is your first time setting up the OHIF Viewer, it is recommended that you
|
|
|
|
|
test with these default settings. After testing, you can find instructions on
|
|
|
|
|
how to configure the project for your own imaging archive below.
|
2019-04-30 05:49:29 +02:00
|
|
|
|
2019-04-30 15:52:51 +02:00
|
|
|
### Configuration
|
2019-04-30 05:49:29 +02:00
|
|
|
|
2019-09-06 16:27:02 +02:00
|
|
|
The configuration for our viewer is in the `<root>platform/viewer/public/config`
|
|
|
|
|
directory. Our build process knows which configuration file to use based on the
|
|
|
|
|
`APP_CONFIG` environment variable. By default, its value is
|
|
|
|
|
[`config/default.js`][default-config]. The majority of the viewer's features,
|
|
|
|
|
and registered extension's features, are configured using this file.
|
2019-04-30 17:56:13 +02:00
|
|
|
|
2019-09-06 16:27:02 +02:00
|
|
|
The easiest way to apply your own configuration is to modify the `default.js`
|
|
|
|
|
file. For more advanced cofiguration options, check out our
|
2019-12-07 06:12:08 +01:00
|
|
|
[configuration essentials guide](/configuring/index.md).
|
2019-04-30 05:49:29 +02:00
|
|
|
|
|
|
|
|
## Next Steps
|
|
|
|
|
|
2019-05-01 17:52:33 +02:00
|
|
|
### Deploying Build Output
|
2019-04-30 05:49:29 +02:00
|
|
|
|
2019-05-01 17:55:58 +02:00
|
|
|
_Drag-n-drop_
|
2019-05-01 17:52:33 +02:00
|
|
|
|
|
|
|
|
- [Netlify: Drop](/deployment/recipes/static-assets.md#netlify-drop)
|
|
|
|
|
|
|
|
|
|
_Easy_
|
|
|
|
|
|
2019-05-01 17:55:58 +02:00
|
|
|
- [Surge.sh](/deployment/recipes/static-assets.md#surgesh)
|
|
|
|
|
- [GitHub Pages](/deployment/recipes/static-assets.md#github-pages)
|
|
|
|
|
|
2019-05-01 17:52:33 +02:00
|
|
|
_Advanced_
|
2019-04-30 05:49:29 +02:00
|
|
|
|
2019-05-01 17:55:58 +02:00
|
|
|
- [AWS S3 + Cloudfront](/deployment/recipes/static-assets.md#aws-s3--cloudfront)
|
|
|
|
|
- [GCP + Cloudflare](/deployment/recipes/static-assets.md#gcp--cloudflare)
|
|
|
|
|
- [Azure](/deployment/recipes/static-assets.md#azure)
|
|
|
|
|
|
2019-04-30 16:39:24 +02:00
|
|
|
### Testing Build Output Locally
|
|
|
|
|
|
|
|
|
|
A quick way to test your build output locally is to spin up a small webserver.
|
2019-09-06 16:27:02 +02:00
|
|
|
You can do this by running the following commands in the `dist/` output
|
2019-04-30 16:39:24 +02:00
|
|
|
directory:
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
// Install http-server as a globally available package
|
|
|
|
|
yarn global add http-server
|
|
|
|
|
|
|
|
|
|
// Serve the files in our current directory
|
|
|
|
|
// Accessible at: `http://localhost:8080`
|
|
|
|
|
http-server
|
|
|
|
|
```
|
|
|
|
|
|
2019-04-30 05:49:29 +02:00
|
|
|
### Automating Builds and Deployments
|
|
|
|
|
|
|
|
|
|
If you found setting up your environmnent and running all of these steps to be a
|
|
|
|
|
bit tedious, then you are in good company. Thankfully, there are a large number
|
|
|
|
|
of tools available to assist with automating tasks like building and deploying
|
|
|
|
|
web application. For a starting point, check out this repository's own use of:
|
|
|
|
|
|
|
|
|
|
- [CircleCI][circleci]: [config.yaml][circleci-config]
|
|
|
|
|
- [Netlify][netlify]: [netlify.toml][netlify.toml] |
|
2019-09-06 16:27:02 +02:00
|
|
|
[build-deploy-preview.sh][build-deploy-preview.sh]
|
2019-04-30 05:49:29 +02:00
|
|
|
|
2019-04-30 15:52:51 +02:00
|
|
|
## Troubleshooting
|
|
|
|
|
|
|
|
|
|
> Issues and resolutions for common GitHub issues will be summarized here
|
|
|
|
|
|
|
|
|
|
...
|
|
|
|
|
|
2019-04-30 05:49:29 +02:00
|
|
|
<!-- prettier-ignore-start -->
|
|
|
|
|
[circleci]: https://circleci.com/gh/OHIF/Viewers
|
2019-09-06 16:27:02 +02:00
|
|
|
[circleci-config]: https://github.com/OHIF/Viewers/blob/master/.circleci/config.yml
|
2019-04-30 05:49:29 +02:00
|
|
|
[netlify]: https://app.netlify.com/sites/ohif/deploys
|
2019-09-06 16:27:02 +02:00
|
|
|
[netlify.toml]: https://github.com/OHIF/Viewers/blob/master/netlify.toml
|
|
|
|
|
[build-deploy-preview.sh]: https://github.com/OHIF/Viewers/blob/master/.netlify/build-deploy-preview.sh
|
2019-04-30 05:49:29 +02:00
|
|
|
<!-- prettier-ignore-end -->
|