nextstrain / nextclade

Viral genome alignment, mutation calling, clade assignment, quality checks and phylogenetic placement
https://clades.nextstrain.org
MIT License
219 stars 58 forks source link

Is there a docker image for the nextclade web interface? #480

Open xzhub opened 3 years ago

xzhub commented 3 years ago

I find the docker for CLI at https://hub.docker.com/r/nextstrain/nextclade, but I'd like to ask if there is any docker I can run locally to use the web interface for data analysis. Thanks!

ivan-aksamentov commented 3 years ago

Hi @xzhub,

No, there isn't. We haven't thought about it. Should not be hard, because Nextclade is just a static React web app. There is no API server, and the analysis is already happening on your computer.

Any reason you don't like using clades.nextstrain.org?

xzhub commented 3 years ago

The lab can't access internet so we have to figure out a way to install it locally. I tried install the web interface like this but it failed:

Dockerfile

FROM node:current-alpine3.14
RUN apk update && apk add bash git
RUN git clone https://github.com/nextstrain/nextclade
RUN sed -e 's/autodetect/localhost/' /nextclade/packages/web/.env.example > /nextclade/packages/web/.env
RUN cd /nextclade/packages/web/ && yarn install && yarn prod:build && \
    yarn autoclean --init && yarn autoclean --force && yarn cache clean
ENTRYPOINT []
WORKDIR /nextclade/packages/web/
CMD ["yarn", "prod:serve"]

Error msg:

 => ERROR [5/6] RUN cd /nextclade/packages/web/ && yarn install && yarn prod:build &&     yarn autoclean --init && yarn aut  195.5s
------                                                                                                                              
 > [5/6] RUN cd /nextclade/packages/web/ && yarn install && yarn prod:build &&     yarn autoclean --init && yarn autoclean --force && yarn cache clean:                                                                                                                 
#9 0.884 yarn install v1.22.5                                                                                                       
#9 1.392 [1/4] Resolving packages...                                                                                                
#9 1.925 warning Resolution field "@babel/runtime@7.11.2" is incompatible with requested version "@babel/runtime@^7.12.0"           
#9 2.187 warning Resolution field "@babel/core@7.11.5" is incompatible with requested version "@babel/core@7.10.5"
#9 2.199 warning Resolution field "@babel/core@7.11.5" is incompatible with requested version "@babel/core@7.10.5"
#9 2.301 warning Resolution field "compression-webpack-plugin@5.0.1" is incompatible with requested version "compression-webpack-plugin@^3.0.1"
#9 2.302 warning Resolution field "css-loader@5.0.1" is incompatible with requested version "css-loader@^2.1.1"
#9 2.318 warning Resolution field "marked@1.1.1" is incompatible with requested version "marked@^0.7.0"
#9 2.318 warning Resolution field "papaparse@5.2.0" is incompatible with requested version "papaparse@^4.3.5"
#9 2.318 warning Resolution field "react-redux@7.2.1" is incompatible with requested version "react-redux@^5.1.0"
#9 2.325 warning Resolution field "style-loader@2.0.0" is incompatible with requested version "style-loader@^0.13.2"
#9 2.325 warning Resolution field "styled-components@5.1.1" is incompatible with requested version "styled-components@^4.0.3"
#9 2.387 warning Resolution field "core-js@3.6.5" is incompatible with requested version "core-js@^1.0.0"
#9 2.400 warning Resolution field "core-js@3.6.5" is incompatible with requested version "core-js@^2.4.0"
#9 2.543 warning Resolution field "lodash@4.17.20" is incompatible with requested version "lodash@^4.17.21"
#9 2.552 warning Resolution field "@babel/core@7.11.5" is incompatible with requested version "@babel/core@7.7.7"
#9 2.558 warning Resolution field "css-loader@5.0.1" is incompatible with requested version "css-loader@4.3.0"
#9 2.566 warning Resolution field "style-loader@2.0.0" is incompatible with requested version "style-loader@1.2.1"
#9 2.772 warning Resolution field "core-js@3.6.5" is incompatible with requested version "core-js@^2.4.1"
#9 3.347 warning Resolution field "@babel/core@7.11.5" is incompatible with requested version "@babel/core@7.9.0"
#9 3.347 warning Resolution field "@babel/plugin-proposal-class-properties@7.10.4" is incompatible with requested version "@babel/plugin-proposal-class-properties@7.8.3"
#9 3.347 warning Resolution field "@babel/plugin-proposal-decorators@7.10.5" is incompatible with requested version "@babel/plugin-proposal-decorators@7.8.3"
#9 3.347 warning Resolution field "@babel/plugin-proposal-numeric-separator@7.10.4" is incompatible with requested version "@babel/plugin-proposal-numeric-separator@7.8.3"
#9 3.348 warning Resolution field "@babel/plugin-transform-flow-strip-types@7.10.4" is incompatible with requested version "@babel/plugin-transform-flow-strip-types@7.9.0"
#9 3.348 warning Resolution field "@babel/plugin-transform-runtime@7.11.5" is incompatible with requested version "@babel/plugin-transform-runtime@7.9.0"
#9 3.349 warning Resolution field "@babel/preset-env@7.11.5" is incompatible with requested version "@babel/preset-env@7.9.0"
#9 3.349 warning Resolution field "@babel/preset-react@7.10.4" is incompatible with requested version "@babel/preset-react@7.9.1"
#9 3.350 warning Resolution field "@babel/runtime@7.11.2" is incompatible with requested version "@babel/runtime@7.9.0"
#9 3.403 warning Resolution field "core-js@3.6.5" is incompatible with requested version "core-js@^2.5.0"
#9 3.827 [2/4] Fetching packages...
#9 101.3 info fsevents@2.1.3: The platform "linux" is incompatible with this module.
#9 101.3 info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
#9 101.3 info fsevents@1.2.13: The platform "linux" is incompatible with this module.
#9 101.3 info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
#9 101.3 [3/4] Linking dependencies...
#9 101.3 warning " > babel-plugin-typescript-to-proptypes@1.3.2" has incorrect peer dependency "typescript@^3.0.0".
#9 101.3 warning " > styled-components@5.1.1" has unmet peer dependency "react-is@>= 16.8.0".
#9 101.3 warning "auspice > react-addons-css-transition-group@15.6.2" has incorrect peer dependency "react@^15.4.2".
#9 101.3 warning " > bootstrap@4.5.2" has unmet peer dependency "jquery@1.9.1 - 3".
#9 101.3 warning " > bootstrap@4.5.2" has unmet peer dependency "popper.js@^1.16.1".
#9 101.3 warning " > connected-next-router@3.1.0" has incorrect peer dependency "next@^9.0.0".
#9 101.3 warning "next > use-subscription@1.5.0" has incorrect peer dependency "react@^17.0.0".
#9 101.3 warning " > react-no-ssr@1.1.0" has incorrect peer dependency "react@^0.14.0 || ^15.0.0".
#9 101.4 warning " > threads-plugin@1.3.3" has unmet peer dependency "@babel/types@>= 7".
#9 101.4 warning " > @testing-library/user-event@12.1.3" has unmet peer dependency "@testing-library/dom@>=7.21.4".
#9 101.4 warning " > babel-plugin-typescript-to-proptypes@1.4.0" has incorrect peer dependency "typescript@^3.0.0".
#9 101.4 warning " > eslint-config-airbnb-typescript@9.0.0" has incorrect peer dependency "@typescript-eslint/eslint-plugin@^3.6.1".
#9 101.4 warning " > eslint-config-react-app@5.2.1" has incorrect peer dependency "@typescript-eslint/eslint-plugin@2.x".
#9 101.4 warning " > eslint-config-react-app@5.2.1" has incorrect peer dependency "@typescript-eslint/parser@2.x".
#9 101.4 warning " > eslint-config-react-app@5.2.1" has unmet peer dependency "babel-eslint@10.x".
#9 101.4 warning " > eslint-config-react-app@5.2.1" has incorrect peer dependency "eslint@6.x".
#9 101.4 warning " > eslint-config-react-app@5.2.1" has incorrect peer dependency "eslint-plugin-flowtype@3.x || 4.x".
#9 101.4 warning " > eslint-config-react-app@5.2.1" has incorrect peer dependency "eslint-plugin-react-hooks@1.x || 2.x".
#9 101.4 warning " > eslint-plugin-sonarjs@0.5.0" has incorrect peer dependency "eslint@^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0".
#9 101.4 warning " > jest-transformer-mdx@2.2.0" has incorrect peer dependency "babel-jest@^24.8.0".
#9 101.4 warning "stylelint-config-primer > stylelint-order@2.2.1" has incorrect peer dependency "stylelint@^9.10.1 || ^10.0.0".
#9 101.4 warning " > stylelint-no-indistinguishable-colors@1.3.0" has incorrect peer dependency "stylelint@^11.1.1".
#9 155.1 [4/4] Building fresh packages...
#9 155.1 warning Ignored scripts due to flag.
#9 155.3 Done in 154.43s.
#9 155.9 yarn run v1.22.5
#9 156.2 $ yarn run monkey-patch && yarn run next:build && yarn run next:export
#9 157.0 $ bash tools/auspice-monkey-patch.sh && bash tools/patch-next.sh
#9 157.9 $ cross-env NODE_ENV=production BABEL_ENV=production NODE_OPTIONS=--max_old_space_size=8192 babel-node --extensions ".js,.ts" -- node_modules/.bin/next build
#9 162.0 Browserslist: caniuse-lite is outdated. Please run:
#9 162.0 npx browserslist@latest --update-db
#9 162.3 Loaded env from /nextclade/packages/web/.env
#9 166.2 Client-side Environment:
#9 166.2 {
#9 166.2   "ENABLE_REDUX_DEV_TOOLS": "true",
#9 166.2   "ENABLE_REDUX_LOGGER": "false",
#9 166.2   "ENABLE_REDUX_IMMUTABLE_STATE_INVARIANT": "false",
#9 166.2   "DEBUG_SET_INITIAL_DATA": "false",
#9 166.2   "BRANCH_NAME": "master",
#9 166.2   "PACKAGE_VERSION": "1.5.2",
#9 166.2   "BUILD_NUMBER": null,
#9 166.2   "TRAVIS_BUILD_WEB_URL": null,
#9 166.2   "COMMIT_HASH": "604af1773760315a5b44534281f57a2c116fb00b",
#9 166.2   "DOMAIN": "https://localhost"
#9 166.2 }
#9 166.3 warn  - You have enabled experimental feature(s).
#9 166.3 warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use them at your own risk.
#9 166.3 
#9 166.3 info  - Creating an optimized production build...
#9 168.4 Browserslist: caniuse-lite is outdated. Please run:
#9 168.4 npx browserslist@latest --update-db
#9 169.2 Browserslist: caniuse-lite is outdated. Please run:
#9 169.2 npx browserslist@latest --update-db
#9 171.1 ℹ Compiling @nextstrain/nextclade-web
#9 171.7 info  - Using external babel configuration from /nextclade/packages/web/babel.config.js
#9 194.4 Failed to compile.
#9 194.4 
#9 194.4 ModuleNotFoundError: Module not found: Error: Can't resolve 'src/generated/wasm/nextclade_wasm.wasm' in '/nextclade/packages/web/src/pages'
#9 194.4 
#9 194.4 
#9 194.4 > Build error occurred
#9 194.5 Error: > Build failed because of webpack errors
#9 194.5     at build (/nextclade/packages/web/node_modules/next/build/index.ts:452:11)
#9 194.5     at runMicrotasks (<anonymous>)
#9 194.5     at processTicksAndRejections (node:internal/process/task_queues:96:5)
#9 194.8 error Command failed with exit code 1.
#9 194.8 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
#9 194.9 error Command failed with exit code 1.
#9 194.9 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
------
executor failed running [/bin/sh -c cd /nextclade/packages/web/ && yarn install && yarn prod:build &&     yarn autoclean --init && yarn autoclean --force && yarn cache clean]: exit code: 1
ivan-aksamentov commented 3 years ago

Nextclade algorithm was recently rewritten in C++, and web version uses it in the form of a WebAssembly (wasm) module, so you need to build wasm first, and then the web app. We haven't updated documentation yet. Sorry about that.

You can reproduce the production build locally using this Makefile target:

make docker-prod-web

https://github.com/nextstrain/nextclade/blob/604af1773760315a5b44534281f57a2c116fb00b/Makefile#L124-L126

It will build:

( See Dockerfile )

The resulting HTML, JS, CSS and other files will be available in:

packages/web/.build/production/web

This directory can be served using any static file server, such as Apache, Nginx, Github Pages, AWS S3+Cloudfront etc.

There is also an Express.js server script in web/tools/server/server.ts. You can invoke it with

cd packages/web
yarn prod:serve

It is only for development purposes and is weak and insecure.

It is important to set FULL_DOMAIN variable to the full address you expect Nextclade to be served from. For example FULL_DOMAIN=https://nextclade.mydomain.com. In case of the server scirpt above it will be autodetected.

Make sure you copy .env.example -> .env

This is roughly how we build Nextclade Web releases on CI server. The target name is Build-Web: .circleci/config.yml

corneliusroemer commented 3 years ago

@ivan-aksamentov would it maybe be an idea to turn nextclade web into a progressive web app, that works offline?

ivan-aksamentov commented 3 years ago

@corneliusroemer Might be nice to have. It is important to not mess up the caching. And data and code updates should be handled well. Contributions welcome.