nextclade icon indicating copy to clipboard operation
nextclade copied to clipboard

Is there a docker image for the nextclade web interface?

Open xzhub opened this issue 3 years ago • 5 comments

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!

xzhub avatar Jul 16 '21 00:07 xzhub

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?

ivan-aksamentov avatar Jul 16 '21 12:07 ivan-aksamentov

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/[email protected]" is incompatible with requested version "@babel/runtime@^7.12.0"           
#9 2.187 warning Resolution field "@babel/[email protected]" is incompatible with requested version "@babel/[email protected]"
#9 2.199 warning Resolution field "@babel/[email protected]" is incompatible with requested version "@babel/[email protected]"
#9 2.301 warning Resolution field "[email protected]" is incompatible with requested version "compression-webpack-plugin@^3.0.1"
#9 2.302 warning Resolution field "[email protected]" is incompatible with requested version "css-loader@^2.1.1"
#9 2.318 warning Resolution field "[email protected]" is incompatible with requested version "marked@^0.7.0"
#9 2.318 warning Resolution field "[email protected]" is incompatible with requested version "papaparse@^4.3.5"
#9 2.318 warning Resolution field "[email protected]" is incompatible with requested version "react-redux@^5.1.0"
#9 2.325 warning Resolution field "[email protected]" is incompatible with requested version "style-loader@^0.13.2"
#9 2.325 warning Resolution field "[email protected]" is incompatible with requested version "styled-components@^4.0.3"
#9 2.387 warning Resolution field "[email protected]" is incompatible with requested version "core-js@^1.0.0"
#9 2.400 warning Resolution field "[email protected]" is incompatible with requested version "core-js@^2.4.0"
#9 2.543 warning Resolution field "[email protected]" is incompatible with requested version "lodash@^4.17.21"
#9 2.552 warning Resolution field "@babel/[email protected]" is incompatible with requested version "@babel/[email protected]"
#9 2.558 warning Resolution field "[email protected]" is incompatible with requested version "[email protected]"
#9 2.566 warning Resolution field "[email protected]" is incompatible with requested version "[email protected]"
#9 2.772 warning Resolution field "[email protected]" is incompatible with requested version "core-js@^2.4.1"
#9 3.347 warning Resolution field "@babel/[email protected]" is incompatible with requested version "@babel/[email protected]"
#9 3.347 warning Resolution field "@babel/[email protected]" is incompatible with requested version "@babel/[email protected]"
#9 3.347 warning Resolution field "@babel/[email protected]" is incompatible with requested version "@babel/[email protected]"
#9 3.347 warning Resolution field "@babel/[email protected]" is incompatible with requested version "@babel/[email protected]"
#9 3.348 warning Resolution field "@babel/[email protected]" is incompatible with requested version "@babel/[email protected]"
#9 3.348 warning Resolution field "@babel/[email protected]" is incompatible with requested version "@babel/[email protected]"
#9 3.349 warning Resolution field "@babel/[email protected]" is incompatible with requested version "@babel/[email protected]"
#9 3.349 warning Resolution field "@babel/[email protected]" is incompatible with requested version "@babel/[email protected]"
#9 3.350 warning Resolution field "@babel/[email protected]" is incompatible with requested version "@babel/[email protected]"
#9 3.403 warning Resolution field "[email protected]" is incompatible with requested version "core-js@^2.5.0"
#9 3.827 [2/4] Fetching packages...
#9 101.3 info [email protected]: The platform "linux" is incompatible with this module.
#9 101.3 info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
#9 101.3 info [email protected]: The platform "linux" is incompatible with this module.
#9 101.3 info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
#9 101.3 [3/4] Linking dependencies...
#9 101.3 warning " > [email protected]" has incorrect peer dependency "typescript@^3.0.0".
#9 101.3 warning " > [email protected]" has unmet peer dependency "react-is@>= 16.8.0".
#9 101.3 warning "auspice > [email protected]" has incorrect peer dependency "react@^15.4.2".
#9 101.3 warning " > [email protected]" has unmet peer dependency "[email protected] - 3".
#9 101.3 warning " > [email protected]" has unmet peer dependency "popper.js@^1.16.1".
#9 101.3 warning " > [email protected]" has incorrect peer dependency "next@^9.0.0".
#9 101.3 warning "next > [email protected]" has incorrect peer dependency "react@^17.0.0".
#9 101.3 warning " > [email protected]" has incorrect peer dependency "react@^0.14.0 || ^15.0.0".
#9 101.4 warning " > [email protected]" has unmet peer dependency "@babel/types@>= 7".
#9 101.4 warning " > @testing-library/[email protected]" has unmet peer dependency "@testing-library/dom@>=7.21.4".
#9 101.4 warning " > [email protected]" has incorrect peer dependency "typescript@^3.0.0".
#9 101.4 warning " > [email protected]" has incorrect peer dependency "@typescript-eslint/eslint-plugin@^3.6.1".
#9 101.4 warning " > [email protected]" has incorrect peer dependency "@typescript-eslint/[email protected]".
#9 101.4 warning " > [email protected]" has incorrect peer dependency "@typescript-eslint/[email protected]".
#9 101.4 warning " > [email protected]" has unmet peer dependency "[email protected]".
#9 101.4 warning " > [email protected]" has incorrect peer dependency "[email protected]".
#9 101.4 warning " > [email protected]" has incorrect peer dependency "[email protected] || 4.x".
#9 101.4 warning " > [email protected]" has incorrect peer dependency "[email protected] || 2.x".
#9 101.4 warning " > [email protected]" has incorrect peer dependency "eslint@^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0".
#9 101.4 warning " > [email protected]" has incorrect peer dependency "babel-jest@^24.8.0".
#9 101.4 warning "stylelint-config-primer > [email protected]" has incorrect peer dependency "stylelint@^9.10.1 || ^10.0.0".
#9 101.4 warning " > [email protected]" 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

xzhub avatar Jul 16 '21 15:07 xzhub

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:

  • "builder" container image (with has C++ build tools and Emscripten)
  • wasm module
  • "web" container image (which has Node.js)
  • web app

( 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

ivan-aksamentov avatar Jul 16 '21 16:07 ivan-aksamentov

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

corneliusroemer avatar Jul 16 '21 16:07 corneliusroemer

@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.

ivan-aksamentov avatar Jul 16 '21 16:07 ivan-aksamentov