Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with the roc-eln-docker_rest-on-couch #39

Open
AlexLeg opened this issue Oct 21, 2021 · 12 comments
Open

Problem with the roc-eln-docker_rest-on-couch #39

AlexLeg opened this issue Oct 21, 2021 · 12 comments
Assignees

Comments

@AlexLeg
Copy link

AlexLeg commented Oct 21, 2021

Hi,
I am a beginner with docker installation.
I am working with Windows, I have installed WSL2 with Ubuntu distribution and Docker Desktop + Visual Code.
I followed the instruction for the installation of the ELN. The containers appear correctly in Docker Desktop but the rest-on-couch one is red and RESTARTING is written below. When I inspect this container, I have the following message:

Error: There must be at least one app key defined in REST_ON_COUCH_APP_KEYS

    at Object.<anonymous> (/rest-on-couch/config.js:7:9)

    at Module._compile (internal/modules/cjs/loader.js:1068:30)

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)

    at Module.load (internal/modules/cjs/loader.js:933:32)

    at Function.Module._load (internal/modules/cjs/loader.js:774:14)

    at Module.require (internal/modules/cjs/loader.js:957:19)

    at require (internal/modules/cjs/helpers.js:88:18)

    at getHomeConfig (/rest-on-couch-source/src/config/home.js:33:18)

    at getConfig (/rest-on-couch-source/src/config/config.js:19:7)

    at Object.<anonymous> (/rest-on-couch-source/src/config/config.js:43:22)

In addition, I am not sure to have correctly modified the .env file

# Local port from which the application will be served
NGINX_PORT=80

# Access to CouchDB admin interface. This port shouldn't be accessible from everywhere
COUCHDB_PORT=4445

# Directory where CouchDB data will be
COUCHDB_DATA_DIRECTORY=./couchdb-data

# Password for the admin user on CouchDB
COUCHDB_ADMIN_PASSWORD=XXXX

# Password for the printer user on CouchDB
COUCHDB_PRINTER_PASSWORD=XXXX

# Password for the rest-on-couch user used by the server
COUCHDB_ROC_SERVER_PASSWORD=XXXX

# Password for the [email protected] user
COUCHDB_ROC_ADMIN_PASSWORD=XXXX

# Debug log level for rest-on-couch services
DEBUG=couch:error,couch:warn,couch:debug

# Name of the session cookie
REST_ON_COUCH_SESSION_KEY=koa:roc-eln

# Domain name(s) that the cookie will be bound to
# Example: server.example.com
REST_ON_COUCH_SESSION_DOMAIN=localhost

# Same as REST_ON_COUCH_SESSION_DOMAIN, only with http:// or https://
# Multiple origins can be specified, separated by a comma
# Example: https://server1.example.com,https://server2.example.com
REST_ON_COUCH_ORIGINS=http://localhost:3000

# Comma-separated keys for signing session cookies
# Each key must be at least 32 characters long
# Can be randomly generated with 'openssl rand -hex 16'
REST_ON_COUCH_APP_KEYS=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

# Comma-separated list of users that have full admin access to rest-on-couch
# [email protected] always has admin access even if this option is not set
REST_ON_COUCH_ADMIN_USERS=

# If your application is behind a reverse proxy, add the prefix here
# Example: app is available at https://server.example.com/my/app. value must be '/my/app'
# When using virtual host it will normaly stay empty
REST_ON_COUCH_PROXY_PATH=

And my docker-compose file is the following

version: "3.3"

# Uncomment if you need to fix the subnet range
#networks:
#  default:
#    driver: bridge
#    ipam:
#      driver: default
#      config:
#        - subnet: 192.168.231.0/24
#          gateway: 192.168.231.1

services:
  nginx-proxy:
    image: docker.io/nginx:1.14-alpine
    ports:
      - "80:80"
    depends_on:
      - rest-on-couch
      - flavor-builder
      - printer-proxy
    volumes:
      - ${PWD}/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
      - ${PWD}/www:/data/www/
      - ${PWD}/nginx/cache:/cache
      - ${PWD}/nginx/certs:/certs
    restart: always
    # uncomment for debugging
    # command: [nginx-debug, '-g', 'daemon off;']

  couchdb:
    image: docker.io/couchdb:2.3.1
    ports:
      - "127.0.0.1:4445:5984"
    environment:
      # CouchDB admin credentials
      COUCHDB_USER: XXXX
      COUCHDB_PASSWORD: XXXX
    volumes:
      - ./couchdb-data:/opt/couchdb/data
      - ${PWD}/couchdb/couch.ini:/opt/couchdb/etc/local.d/couch.ini
    restart: always

  rest-on-couch:
    build: ./rest-on-couch
    command:  "/start.sh" 
    environment:
      # CouchDB admin credentials
      COUCHDB_USER: XXXX
      COUCHDB_PASSWORD: XXXX
    expose:
      - 3000
    volumes:
      - ./rest-on-couch-home:/rest-on-couch
    depends_on:
      - couchdb
    restart: always
    env_file:
      - .env

#  rest-on-couch-import:
#    build: ./rest-on-couch
#    command: >
#      bash -c "node /rest-on-couch-source/bin/rest-on-couch-import.js --continuous"
#    environment:
#      # CouchDB admin credentials
#      COUCHDB_USER: admin
#      COUCHDB_PASSWORD: ${COUCHDB_ADMIN_PASSWORD}
#    volumes:
#      - ./rest-on-couch-home:/rest-on-couch
#      - ./rest-on-couch-home:/rest-on-couch-home
#    depends_on:
#      - couchdb
#      - rest-on-couch # make sure that not both try to create the db at the same time
#    restart: always
#    env_file:
#      - .env

  #  To enable the service, uncomment here and edit ./nginx-proxy/conf.nginx
  #  rest-on-couch-file-drop:
  #    build: ./rest-on-couch
  #    command: node /rest-on-couch-source/bin/rest-on-couch-file-drop.js
  #    depends_on:
  #      - couchdb
  #    expose:
  #      - 3001
  #    restart: always
  #    env_file:
  #      - .env

  flavor-builder:
    image: docker.io/cheminfo/eln-flavor-builder:v2.0.2
    environment:
      DEBUG: "flavor-builder*"
      COUCHDB_USER: XXXX
      COUCHDB_PASSWORD: XXXX
    volumes:
      - ${PWD}/flavor-builder-config.json:/flavor-config.json
      - ${PWD}/www:/var/www/html/
     # - ./flavor-builder-on-tabs-config.json:/on-tabs-config.json
    depends_on:
      - couchdb
      - rest-on-couch
    restart: always

  printer-proxy:
    image: docker.io/cheminfo/eln-printer-proxy:v1.3.4
    command: pm2-docker start /pm2-proxy.yml
    volumes:
      - ${PWD}/printer-proxy-config.yml:/config.yml
      # Uncomment to use a custom pm2 config
      # This should normally not be necessary
      #- ./pm2/printer-proxy.yml:/pm2-proxy.yml
    depends_on:
      - rest-on-couch
    expose:
      - 7770
    restart: always

Your advice and help will be really appreciated

@kjappelbaum kjappelbaum self-assigned this Oct 21, 2021
@kjappelbaum
Copy link
Collaborator

kjappelbaum commented Oct 21, 2021

Thanks for your feedback. 👍🏽

One immediate note is that

# Comma-separated keys for signing session cookies
# Each key must be at least 32 characters long
# Can be randomly generated with 'openssl rand -hex 16'
REST_ON_COUCH_APP_KEYS=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

not compliant with the instructions. You seem to have only 30 characters.
Can you maybe check this first and if this does not work out, I'll try to reproduce your issue

@AlexLeg
Copy link
Author

AlexLeg commented Oct 21, 2021

Thanks for your quick answer.
Actually the key is the followings d2844e7564bdca3cce64248440e2d204
But even with it it still doesnt work

@AlexLeg
Copy link
Author

AlexLeg commented Oct 21, 2021

I don't know if it may help but the printer-proxy-config.yml file is the `following:

rest-on-couch:
  url: http://localhost:3000/ # Change to appropriate rest-on-couch url
  database: printers # in most cases no need to change this
  username: [email protected] # DO NOT CHANGE
  password: XXXX # change here

@kjappelbaum
Copy link
Collaborator

Thanks, I was busy the last two weeks but can you -- if I forget -- remind me next week. We will get this solved

@AlexLeg
Copy link
Author

AlexLeg commented Nov 4, 2021

Hi,
yes sure i will do next week,
thanks

@AlexLeg
Copy link
Author

AlexLeg commented Nov 9, 2021

Hi,
As you ask, a reminder for this week

@kjappelbaum
Copy link
Collaborator

Hi, I struggle to reproduce your problem (fresh clone on Mac OS and Ubuntu using something similar to your env file). Do you run the thing from WSL or Windows?

@AlexLeg
Copy link
Author

AlexLeg commented Nov 12, 2021

Hi, I did the installation with WSL and the run everything with DOcker Desktop for Windows
image
If i check the roc-eln-docker_rest-on-couch_1 container I have the following:

 code: undefined,

  timings: {

    start: 1636692384719,

    socket: 1636692384722,

    lookup: 1636692384724,

    connect: 1636692384725,

    secureConnect: undefined,

    upload: 1636692384725,

    response: 1636692384730,

    end: 1636692384738,

    error: undefined,

    abort: undefined,

    phases: {

      wait: 3,

      dns: 2,

      tcp: 1,

      tls: undefined,

      request: 0,

      firstByte: 5,

      download: 8,

      total: 19

    }

  }

}

2021-11-12T04:46:28.419Z couch:debug (config:cli) no cli config

2021-11-12T04:46:28.545Z couch:debug (roc:env-config) setting config from env, sessionKey: koa:roc-eln

2021-11-12T04:46:28.545Z couch:debug (roc:env-config) setting config from env, sessionDomain: localhost

2021-11-12T04:46:28.545Z couch:debug (roc:env-config) setting config from env, homeDir: /rest-on-couch

2021-11-12T04:46:28.545Z couch:debug (roc:env-config) setting config from env, origins: http://localhost:3000

2021-11-12T04:46:28.545Z couch:debug (roc:env-config) setting config from env, proxyPath: 

2021-11-12T04:46:28.546Z couch:debug (roc:env-config) setting config from env, adminUsers: 

Response to database query: 401

Response: 401

CouchDB is already initialized

audited 103 packages in 1.107s


9 packages are looking for funding

  run `npm fund` for details


found 0 vulnerabilities


2021-11-12T04:46:28.546Z couch:debug (roc:env-config) setting config from env, appKeys: d2844e7564bdca3cce64248440e2d204

2021-11-12T04:46:28.546Z couch:debug (config:home) get home dir config from /rest-on-couch

2021-11-12T04:46:28.546Z couch:debug (config:home) loaded main config file

2021-11-12T04:46:28.713Z couch:debug (auth) loading auth plugin: couchdb

2021-11-12T04:46:28.716Z couch:debug (auth) auth plugin successfully loaded

2021-11-12T04:46:28.716Z couch:debug (auth) plugin google not configured

2021-11-12T04:46:28.716Z couch:debug (auth) plugin facebook not configured

2021-11-12T04:46:28.716Z couch:debug (auth) plugin github not configured

2021-11-12T04:46:28.716Z couch:debug (auth) plugin ldap not configured

2021-11-12T04:46:28.716Z couch:debug (server) proxy prefix: /roc

2021-11-12T04:46:28.717Z couch:debug (server) allowed cors origins: [ 'http://localhost:3000' ]

2021-11-12T04:46:28.719Z couch:debug (main:connect) initialize connection to CouchDB

2021-11-12T04:46:28.737Z couch:error (server) initialization failed

/rest-on-couch-source/src/server/server.js:141

          throw e;

          ^


HTTPError: Response code 401 (Unauthorized)

    at Request.<anonymous> (/rest-on-couch-source/node_modules/got/dist/source/as-promise/index.js:117:42)

    at processTicksAndRejections (internal/process/task_queues.js:95:5) {

  code: undefined,

  timings: {

    start: 1636692388727,

    socket: 1636692388729,

    lookup: 1636692388730,

    connect: 1636692388730,

    secureConnect: undefined,

    upload: 1636692388731,

    response: 1636692388732,

    end: 1636692388735,

    error: undefined,

    abort: undefined,

    phases: {

      wait: 2,

      dns: 1,

      tcp: 0,

      tls: undefined,

      request: 1,

      firstByte: 1,

      download: 3,

      total: 8

    }

  }

}

2021-11-12T04:46:32.156Z couch:debug (config:cli) no cli config

2021-11-12T04:46:32.304Z couch:debug (roc:env-config) setting config from env, sessionKey: koa:roc-eln

Response to database query: 401

Response: 401

CouchDB is already initialized

audited 103 packages in 1.304s


9 packages are looking for funding

  run `npm fund` for details


found 0 vulnerabilities

@kjappelbaum
Copy link
Collaborator

Hm, I'll try to get a Windows machine to replicate this. Can you confirm that you run it via:

  1. git clone of the repo
  2. docker-compose up -d --build

with an env file similar to

# Local port from which the application will be served
NGINX_PORT=80

# Access to CouchDB admin interface. This port shouldn't be accessible from everywhere
COUCHDB_PORT=4445

#COUCHDB_HOST='couchdb'

# Directory where CouchDB data will be
COUCHDB_DATA_DIRECTORY=./couchdb-data

# Password for the admin user on CouchDB
COUCHDB_ADMIN_PASSWORD=REPLACEME

# Password for the printer user on CouchDB
COUCHDB_PRINTER_PASSWORD=REPLACEME

# Password for the rest-on-couch user used by the server
COUCHDB_ROC_SERVER_PASSWORD=REPLACEME

# Password for the [email protected] user
COUCHDB_ROC_ADMIN_PASSWORD=REPLACEME

# Debug log level for rest-on-couch services
DEBUG=couch:error,couch:warn,couch:debug

# Name of the session cookie
REST_ON_COUCH_SESSION_KEY=koa:roc-eln

# Domain name(s) that the cookie will be bound to
# Example: server.example.com
REST_ON_COUCH_SESSION_DOMAIN=localhost

# Same as REST_ON_COUCH_SESSION_DOMAIN, only with http:// or https://
# Multiple origins can be specified, separated by a comma
# Example: https://server1.example.com,https://server2.example.com
REST_ON_COUCH_ORIGINS=http://localhost:3000

# Comma-separated keys for signing session cookiesa
# Each key must be at least 32 characters long
# Can be randomly generated with 'openssl rand -hex 16'
REST_ON_COUCH_APP_KEYS=6c401816154c1d34089299e787c4f945

# Comma-separated list of users that have full admin access to rest-on-couch
# [email protected] always has admin access even if this option is not set
REST_ON_COUCH_ADMIN_USERS=

# If your application is behind a reverse proxy, add the prefix here
# Example: app is available at https://server.example.com/my/app. value must be '/my/app'
# When using virtual host it will normaly stay empty
REST_ON_COUCH_PROXY_PATH=

@AlexLeg
Copy link
Author

AlexLeg commented Nov 16, 2021

Yes I checked, the env file is the same

Here is the cmd list I used for the installation on WSL (Ubuntu distri)

If you think it is necessary, we can plan a zoom call and redo the installation together?

391  epel-release
  392  cd
  393  mkdir cheminfo
  394  cd cheminfo
  395  history
  396  sudo apt-get install epel-release -y
  397  curl -sL https://rpm.nodesource.com/setup_14.x | bash -
  398  apt-get install curl
  399  sudo apt-get install curl
  400  sudo apt autoremove
  401  curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
  402  command -v nvm
  403  nvm ls
  404  nvm install --lts
  405  nvm ls
  406  node --version
  407  npm --version
  408  systemctl start docker
  409  docker-compose ps
  410  cd
  411  ls
  412  cd cheminfo
  413  curl -L https://github.com/cheminfo/roc-eln-docker/archive/master.tar.gz | tar xz
  414  mv roc-eln-docker-master roc-eln-docker
  415  cd roc-eln-docker
  416  ci/install.sh
  417  sudo ci/install.sh
  418  docker-compose up -d
  419  cd rest-on-couch/home
  420  ls
  421  cd rest-on-couch
  422  ls
  423  cd ..
  424  ls
  425  cd rest-on-couch-home
  426  ls
  427  cd visualizer
  428  ls
  429  curl -L https://github.com/cheminfo/roc-visualizer-config/archive/master.tar.gz | tar xz
  430  mv roc-visualizer-config-master visualizer
  431  cd ..
  432  ls
  433  cd eln
  434  curl -L https://github.com/cheminfo/roc-eln-config/archive/master.tar.gz | tar xz
  435  mv roc-eln-config-master eln
  436  cd ..
  437  cd printers
  438  curl -L https://github.com/cheminfo/roc-printers-config/archive/master.tar.gz | tar xz
  439  mv roc-printers-config-master printers
  440  cd ..
  441  docker-compose pull
  442  docker-compose up -d --build
  443  ls
  444  cd ci
  445  install.sh
  446  docker-compose up -d
  447  cd ..
  448  docker-compose pull
  449  docker-compose up -d --build
  450  docker ps
  451  curl 80:80/ping
  452  docker-compose down --remove-orphans
  453  docker-compose up -d --build
  454  docker-compose down --remove-orphans
  455  docker-compose pull
  456  docker-compose up -d --build
  457  docker-compose down --remove-orphans
  458  docker-compose pull
  459  docker-compose up -d --build
  460  docker-compose down --remove-orphans
  461  docker-compose pull
  462  docker-compose up -d --build
  463  docker-compose down --remove-orphans
  464  docker-compose pull
  465  docker-compose up -d --build
  466  docker-compose down --remove-orphans
  467  docker-compose pull
  468  docker-compose up -d --build
  469  docker-compose down --remove-orphans
  470  docker-compose pull
  471  docker-compose up -d --build
  472  docker-compose down --remove-orphans
  473  docker-compose pull
  474  docker-compose up -d --build
  475  openssl rand -hex 16
  476  docker-compose down --remove-orphans
  477  docker-compose pull
  478  docker-compose up -d --build

@kjappelbaum
Copy link
Collaborator

Really sorry for the delay. We ran some tests internally and

# Local port from which the application will be served
NGINX_PORT=4444

# Access to CouchDB admin interface. This port shouldn't be accessible from everywhere
COUCHDB_PORT=4445

#COUCHDB_HOST='couchdb'

# Directory where CouchDB data will be
COUCHDB_DATA_DIRECTORY=./couchdb-data

# Password for the admin user on CouchDB
COUCHDB_ADMIN_PASSWORD=REPLACEME

# Password for the printer user on CouchDB
COUCHDB_PRINTER_PASSWORD=REPLACEME

# Password for the rest-on-couch user used by the server
COUCHDB_ROC_SERVER_PASSWORD=REPLACEME

# Password for the [email protected] user
COUCHDB_ROC_ADMIN_PASSWORD=REPLACEME

# Debug log level for rest-on-couch services
DEBUG=couch:error,couch:warn,couch:debug

# Name of the session cookie
REST_ON_COUCH_SESSION_KEY=koa:roc-eln

# Domain name(s) that the cookie will be bound to
# Example: server.example.com
REST_ON_COUCH_SESSION_DOMAIN=127.0.0.1

# Same as REST_ON_COUCH_SESSION_DOMAIN, only with http:// or https://
# Multiple origins can be specified, separated by a comma
# Example: https://server1.example.com,https://server2.example.com
REST_ON_COUCH_ORIGINS=127.0.0.1

# Comma-separated keys for signing session cookiesa
# Each key must be at least 32 characters long
# Can be randomly generated with 'openssl rand -hex 16'
REST_ON_COUCH_APP_KEYS=6c401816154c1d34089299e787c4f945

# Comma-separated list of users that have full admin access to rest-on-couch
# [email protected] always has admin access even if this option is not set
REST_ON_COUCH_ADMIN_USERS=

# If your application is behind a reverse proxy, add the prefix here
# Example: app is available at https://server.example.com/my/app. value must be '/my/app'
# When using virtual host it will normaly stay empty
REST_ON_COUCH_PROXY_PATH=

reproducibly works (however, the doc was out of date).

If you want to schedule a zoom you can find my contact details at kjablonka.com

@AlexLeg
Copy link
Author

AlexLeg commented Jan 19, 2022

Hi! All the best for 2022!
I follow your instruction after restarting the installation procedure from the beginning and now it's working perfectly fine!
It is now installed locally but I am not sure to understand well how to make it accessible on a local network for over to use it.
Is this requiring the setting of an Apache server?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants