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

Node.js issue when deploying with Docker #831

Open
dancesWithCycles opened this issue Aug 9, 2022 · 14 comments
Open

Node.js issue when deploying with Docker #831

dancesWithCycles opened this issue Aug 9, 2022 · 14 comments

Comments

@dancesWithCycles
Copy link
Contributor

Hi folks,
Thank you so much for providing and maintaining this repository! Kudos!

Observed behavior

With all configurations I tried so far the Docker container for datatools-ui is terminating after seconds with the following reply.

datatools-ui       | done building...
datatools-ui       | /usr/local/lib/node_modules/serve/build/main.js:4
datatools-ui       | import path from "node:path";
datatools-ui       |        ^^^^
datatools-ui       | 
datatools-ui       | SyntaxError: Unexpected identifier
datatools-ui       |     at Module._compile (internal/modules/cjs/loader.js:723:23)
datatools-ui       |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
datatools-ui       |     at Module.load (internal/modules/cjs/loader.js:653:32)
datatools-ui       |     at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
datatools-ui       |     at Function.Module._load (internal/modules/cjs/loader.js:585:3)
datatools-ui       |     at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
datatools-ui       |     at startup (internal/bootstrap/node.js:283:19)
datatools-ui       |     at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
datatools-ui exited with code 1

Expected behavior

I expected the datatools-ui container to run in an orchestra together with the other four container for datatools-server, postgres, nginx and mongodb.

Steps to reproduce the problem

I am using the following repository to configure the Docker composition.

https://github.com/javandres/gtfs_editor_ibi_datatools_docker

Any special notes on configuration used

I adjusted the Dockerfile of the repository for datatools-ui and tried the following settings one after another.

FROM node:10
RUN  git clone -b 'merge-pr-#821' --single-branch https://github.com/Software-Ingenieur-Begerad/datatools-ui.git /opt/datatools-ui
FROM node:10
RUN  git clone -b 'merge-pr-#826' --single-branch https://github.com/Software-Ingenieur-Begerad/datatools-ui.git /opt/datatools-ui
FROM node:12
RUN  git clone -b 'merge-pr-#821' --single-branch https://github.com/Software-Ingenieur-Begerad/datatools-ui.git /opt/datatools-ui
FROM node:12
RUN  git clone -b 'merge-pr-#826' --single-branch https://github.com/Software-Ingenieur-Begerad/datatools-ui.git /opt/datatools-ui
FROM node:12
RUN  git clone -b 'dev' --single-branch https://github.com/Software-Ingenieur-Begerad/datatools-ui.git /opt/datatools-ui
FROM node:14
RUN  git clone -b 'dev' --single-branch https://github.com/Software-Ingenieur-Begerad/datatools-ui.git /opt/datatools-ui

No matter what settings, I am ending up with the same failure killing the datatools-ui container after a couple of seconds.

I am appreciating any hint that helps me tackle this issue.

Cheers!

@dancesWithCycles
Copy link
Contributor Author

Hi @wkulesza,
This is the issue I mentioned recently. I am looking for the right track to setup Datatools-UI using Docker with a working branch and configuration. Do you share how you setup the Dockerfile?

Cheers!

@miles-grant-ibigroup
Copy link
Contributor

Thanks for reporting this! We've experimented with dockerizing datatools-ui (and the server) in the past, and it's definitely something we're interested in doing.

We ran into similar issues when we were setting it up. It seems to be an issue with mastarm.

The solution we came up with was the following:

# syntax=docker/dockerfile:1
FROM node:14
WORKDIR /datatools-build
RUN cd /datatools-build
COPY package.json yarn.lock /datatools-build/
RUN yarn
COPY . /datatools-build/ 
COPY configurations/default /datatools-config/
RUN yarn run build --minify -c /datatools-config

FROM nginx
COPY --from=0 /datatools-build/dist /usr/share/nginx/html/dist/
EXPOSE 80 

Please keep in mind that this is very experimental and will probably not work out of the box, however I hope it may help you get on the right path towards getting things working! If you do get it working, please do report back here and we might be able to upstream some of your work.

@dancesWithCycles
Copy link
Contributor Author

Hi @miles-grant-ibigroup ,
Thank you so much for the hint. I'll touch base with my experiences. Cheers!

@dancesWithCycles
Copy link
Contributor Author

Hi @miles-grant-ibigroup ,
In the Dockerfile above, how come you copy single configuration files

COPY package.json yarn.lock /datatools-build/

and afterwords the entire folder content

COPY . /datatools-build/

to the same target folder?

On the first glance, it looks like the first copy operation is redundant. What is your opinion on this?

@miles-grant-ibigroup
Copy link
Contributor

We found that some of the other files in the directory sometimes interfere with the yarn install. As I said this docker file was quite experimental and a "production" version probably wouldn't need this better-safe-than-sorry extra copy.

Hope that's helpful!

@wkulesza
Copy link

@dancesWithCycles @miles-grant-ibigroup hi, we successfully managed to get DT running in docker using this setup: https://github.com/javandres/gtfs_editor_ibi_datatools_docker
let me know if that helps - from my experience the most problematic thing is the auth0. Also, dynamic urls are created (like ....:port/login when clicking on login button on welcome screen) and then, when i try to refresh the page, i'm getting 404 The requested path could not be found message on white screen.

@miles-grant-ibigroup
Copy link
Contributor

Glad you were able to get it working @wkulesza! Good news about auth0 we are currently in the process of upgrading the version of the auth0 library we use and that should resolve some of the issues you're having!

@dancesWithCycles
Copy link
Contributor Author

Hi @wkulesza ,
Do you mind sharing your version of the Dockerfile? The key I am missing is to get the datatools-ui container running without failing after a couple of seconds.

@wkulesza
Copy link

wkulesza commented Aug 12, 2022

Sure:

FROM node:14
 
ENV VERSION=v5.0.0
 
RUN apt-get update && \
    apt-get install -y --no-install-recommends gettext-base && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*
 
RUN npm i -g serve
 
RUN  git clone -b 'dev' --single-branch https://github.com/ibi-group/datatools-ui.git /opt/datatools-ui
 
WORKDIR /opt/datatools-ui
 
ADD ./config/*.yml /config/
 
RUN yarn
 
COPY /config/settings.yml /opt/datatools-ui/configurations/default/settings.yml
 
EXPOSE 9966
 
CMD envsubst < /config/env.yml > /opt/datatools-ui/configurations/default/env.yml && \
    $(npm bin)/mastarm build --env dev && serve -p 9966

@dancesWithCycles
Copy link
Contributor Author

Hi folks,
I have the feeling that the reason for this issue is something else.

@wkulesza: May I ask you what operating system version you are using as host? Do you mind sharing something like this.

$ uname -a
Linux vm2037 5.10.0-14-amd64 #1 SMP Debian 5.10.113-1 (2022-04-29) x86_64 GNU/Linux
$ cat /etc/debian_version 
11.3

@dancesWithCycles
Copy link
Contributor Author

@wkulesza Do you mind sharing something like this.

$ docker -v
Docker version 20.10.16, build aa7e414

@dancesWithCycles
Copy link
Contributor Author

@wkulesza Do you mind sharing something like this.

yarn --version

@dancesWithCycles
Copy link
Contributor Author

Is is a little bit daunting. No matter what I did so far, the datatools-ui container keeps failing after seconds like this.

datatools-ui       | done building...
datatools-ui       | /usr/local/lib/node_modules/serve/build/main.js:4
datatools-ui       | import path from "node:path";
datatools-ui       |        ^^^^
datatools-ui       | 
datatools-ui       | SyntaxError: Unexpected identifier
datatools-ui       |     at Module._compile (internal/modules/cjs/loader.js:723:23)
datatools-ui       |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
datatools-ui       |     at Module.load (internal/modules/cjs/loader.js:653:32)
datatools-ui       |     at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
datatools-ui       |     at Function.Module._load (internal/modules/cjs/loader.js:585:3)
datatools-ui       |     at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
datatools-ui       |     at startup (internal/bootstrap/node.js:283:19)
datatools-ui       |     at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
datatools-ui exited with code 1

My motivation is gone now. I am going for a motivation hunt next week to figure out how to proceed. Thanks everyone for all the help already. Cheers!

@wkulesza
Copy link

wkulesza commented Aug 17, 2022

@dancesWithCycles - sure, but i dont think it matters, as everything happens in the docker.

uname -a
Linux vps-68526314 4.19.0-16-cloud-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 GNU/Linux
cat /etc/debian_version
10.12
docker -v
Docker version 20.10.10, build b485636

Let me know how you get on ?

Good idea is to go to /var/lib/docker/containers/ - there you should see each container and inside, you have a log file that would show you what's wrong.

if a docker container is stopped, make sure to see which id it has using docker ps -a

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

3 participants