Deployment, UI compiling twice, token error and eslint


Dear community and kobo developers!

Pardon me if my questions are still quite noobish … the learning curve for this stack is steep.

I would like to ask if anyone has had a detailed look at the outputs during a local deployment, when building (not pulling) kpi.

My understanding is that npm run build and python collecstatic --noinput are run a first time in the Dockerfile. BUT … I cannot understand how and why it is run again when I do docker-compose up!

I did check the /kpi/docker/init.bash and can see:

if [[ ! -d "${KPI_SRC_DIR}/staticfiles" ]] || ! python "${KPI_SRC_DIR}/docker/"; then
    echo 'Building static files from live code.'
    (cd "${KPI_SRC_DIR}" && npm run build && python collectstatic --noinput)

KPI_PREFIX is set to be KPI_PREFIX=/ in the env_file: ./envfiles/kpi.txt. Thus, when running docker-compose up everything should be fine! And the variable available in the environment. But the python script always fails because of a key error ['KPI_PREFIX']. hence … it compiles everything again at deployment. Meanwhile, the other containers are waiting for kpi to be up …

Last but not least, I cannot understand the following:

  1. If uncomment multiple lines in /kpi/jsapp/js/components/header.es6 using {/* */} (as I understand it should be done in .es6 files.
  2. Then npm run build during the build of kpi works fine!
  3. But, when docker-compose up … it tries to compile again (see aforementioned issue) and suddenly fails with a token error pointing at the ending } of my uncommented lines and sends me an error referring to /srv/src/kpi/node_modules/eslint-loader/index.js.

If anyone could help, it would be much appreciated :slight_smile: cause I am pulling my hair at the moment.




Hi Michel-Pierre,

I don’t have the trouble with that you do. The KeyError would indicate that KPI_PREFIX is missing from the environment, no? Here’s what I see from within my kpi container:

root@kpi:/srv/src/kpi# echo $KPI_PREFIX
root@kpi:/srv/src/kpi# python docker/ && echo 'Great!'

Regarding changes to header.es6, it’s worth noting the distinction between ES6 and JSX. You’ll find JSX (it resembles HTML) within KoBo’s ES6 files, due to the use of React, and inside JSX you do need to surround comments with braces. However, ES6 itself uses the familiar /* */ and // comments.

It’s odd that the npm run build during the Docker build works but docker-compose up does not. If eslint is to blame, you can try disabling it by commenting out or removing these lines in the webpack configuration: