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

openboxes-docker out update #16

Open
thientech opened this issue May 19, 2023 · 9 comments
Open

openboxes-docker out update #16

thientech opened this issue May 19, 2023 · 9 comments

Comments

@thientech
Copy link

I have setup on docker but debian not support. Help me

@GilDev
Copy link

GilDev commented May 30, 2023

Same, I have tried on multiple targets (armv7 with a different mysql image, amd64 on Ubuntu and macOS) without luck. Here’s the log when building the image:

 => ERROR [ 3/14] RUN apt-get update && apt-get install -y curl zip python g++ make gcc build-essential     && curl -sL https:  2.3s
------
 > [ 3/14] RUN apt-get update && apt-get install -y curl zip python g++ make gcc build-essential     && curl -sL https://deb.nodesource.com/setup_13.x | bash -     && apt-get install -y nodejs     && curl -L https://www.npmjs.com/install.sh | sh:
#0 2.135 Ign http://security.debian.org jessie/updates InRelease
#0 2.150 Ign http://security.debian.org jessie/updates Release.gpg
#0 2.164 Ign http://security.debian.org jessie/updates Release
#0 2.167 Ign http://deb.debian.org jessie InRelease
#0 2.178 Err http://security.debian.org jessie/updates/main amd64 Packages
#0 2.178
#0 2.187 Err http://security.debian.org jessie/updates/main amd64 Packages
#0 2.187
#0 2.189 Ign http://deb.debian.org jessie Release.gpg
#0 2.205 Err http://security.debian.org jessie/updates/main amd64 Packages
#0 2.205
#0 2.213 Ign http://deb.debian.org jessie Release
#0 2.220 Err http://security.debian.org jessie/updates/main amd64 Packages
#0 2.220
#0 2.230 Err http://security.debian.org jessie/updates/main amd64 Packages
#0 2.230   404  Not Found [IP: 151.101.2.132 80]
#0 2.233 Err http://deb.debian.org jessie/main amd64 Packages
#0 2.233
#0 2.253 Err http://deb.debian.org jessie/main amd64 Packages
#0 2.253
#0 2.275 Err http://deb.debian.org jessie/main amd64 Packages
#0 2.275
#0 2.295 Err http://deb.debian.org jessie/main amd64 Packages
#0 2.295
#0 2.314 Err http://deb.debian.org jessie/main amd64 Packages
#0 2.314   404  Not Found
#0 2.315 W: Failed to fetch http://security.debian.org/debian-security/dists/jessie/updates/main/binary-amd64/Packages  404  Not Found [IP: 151.101.2.132 80]
#0 2.315
#0 2.315 W: Failed to fetch http://deb.debian.org/debian/dists/jessie/main/binary-amd64/Packages  404  Not Found
#0 2.315
#0 2.315 E: Some index files failed to download. They have been ignored, or old ones used instead.
------
failed to solve: executor failed running [/bin/sh -c apt-get update && apt-get install -y curl zip python g++ make gcc build-essential     && curl -sL https://deb.nodesource.com/setup_13.x | bash -     && apt-get install -y nodejs     && curl -L https://www.npmjs.com/install.sh | sh]: exit code: 100

@GilDev
Copy link

GilDev commented Jun 1, 2023

Managed to go forward with this but now I’m stuck on issue #10.

Here’s my modified Dockerfile:

FROM openjdk:7-jdk

MAINTAINER Michael Seaton <mseaton@pih.org>

# Environment variables

ENV SDKMAN_DIR /root/.sdkman
ENV GRAILS_VERSION 1.3.9

# Install Base Packages required and Node
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -

RUN rm /etc/apt/sources.list
RUN apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com 7638D0442B90D010
RUN echo "deb http://archive.debian.org/debian/ jessie main" | tee -a /etc/apt/sources.list
RUN echo "deb-src http://archive.debian.org/debian/ jessie main" | tee -a /etc/apt/sources.list
RUN echo "Acquire::Check-Valid-Until false;" | tee -a /etc/apt/apt.conf.d/10-nocheckvalid
RUN echo 'Package: *\nPin: origin "archive.debian.org"\nPin-Priority: 500' | tee -a /etc/apt/preferences.d/10-archive-pin

RUN apt-get update
RUN apt-get install -y --force-yes aptitude
RUN aptitude install -y --allow-untrusted curl zip python g++ make gcc build-essential apt-transport-https lsb-release
#RUN apt-get update && apt-get install -y curl zip python g++ make gcc build-essential \
RUN curl -sL https://deb.nodesource.com/setup_13.x | bash - \
RUN aptitude install -y nodejs \
RUN curl -L https://www.npmjs.com/install.sh | sh

# Install Grails and Set Path
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
RUN curl -s "https://get.sdkman.io" | bash
RUN chmod a+x "$SDKMAN_DIR/bin/sdkman-init.sh"

# change timeout and max time based on your liking and internet speed
RUN set -x \
    && echo "sdkman_auto_answer=true" > $SDKMAN_DIR/etc/config \
    && echo "sdkman_auto_selfupdate=false" >> $SDKMAN_DIR/etc/config \
    && echo "sdkman_curl_connect_timeout=20" >> $SDKMAN_DIR/etc/config \
    && echo "sdkman_curl_max_time=0" >> $SDKMAN_DIR/etc/config \
    && echo "sdkman_insecure_ssl=false" >> $SDKMAN_DIR/etc/config

WORKDIR $SDKMAN_DIR
RUN [[ -s "$SDKMAN_DIR/bin/sdkman-init.sh" ]] && source "$SDKMAN_DIR/bin/sdkman-init.sh" && exec "$@"

RUN source /root/.bashrc

# install and set grails version
RUN bash -c "source $SDKMAN_DIR/bin/sdkman-init.sh && sdk install grails $GRAILS_VERSION"
RUN bash -c "source $SDKMAN_DIR/bin/sdkman-init.sh && sdk default grails $GRAILS_VERSION"

# set envs
ENV JAVA_HOME /usr/lib/jvm/java-7-openjdk-amd64
ENV GRAILS_HOME /root/.sdkman/candidates/grails/current
ENV PATH $GRAILS_HOME/bin:$PATH
ENV GRAILS_OPTS -XX:-UseSplitVerifier -Xverify:none

# Set the directory that an existing Grails app should be mounted into with a volume
RUN mkdir /app
WORKDIR /app

EXPOSE 8080

CMD ["grails"]

@ookjosh
Copy link

ookjosh commented Sep 19, 2023

I was able to update the dockerfile to get OpenBoxes running. This is a longer-form walk through of my process in case it helps people for future issues - feel free to skip to the end, and please let me know if it works for you too!

Diagnosing/Update Process

  1. Migrated from openjdk-7 base image to the azul image
  • Since openboxes uses azul jdk this seems a safe choice
  • The openjdk base image is based on an older version of debian, and the repo URLs are out of date
    • This is why the apt updates were failing
    • As @GilDev noted, an option is to update the urls to the archive versions - but having a more modern base may be helpful/easier?
  1. The nodejs installation in the dockerfile was no longer compatible, so I locked it to Node 14 and updated the installation commands
  2. From here I had a dockerfile that at least got to gradle, but ran into a couple more issues trying to get things up
  • I ran into out of memory exceptions
    • I added -XX:MaxPermSize=8192m and -Xmx8192M to GRAILS_OPTS in dockerfile
    • I also added the above to openboxes-run.sh since it overrode the Dockerfile ENV setting
  1. Around this point I had a working setup:
  • Run docker compose up --build
    • Will fail, according to the docs this is expected?
  • Run docker compose up
    • Liquibase migrations ran (and took a long time, maybe 10-15 minutes? But output was consistently moving)
    • After migrations ran there was a pause with no output (validation I'm assuming)
    • A few more items completed, then I could reach the page at localhost:8080/openboxes

Updated Dockerfile

# Azul image is more modern/better maintained
#FROM openjdk:7-jdk
FROM azul/zulu-openjdk:7

MAINTAINER Michael Seaton <mseaton@pih.org>

# Environment variables

ENV SDKMAN_DIR /root/.sdkman
ENV GRAILS_VERSION 1.3.9
ENV NODE_VERSION=14.0.0


# Install Base Packages required
RUN apt-get update && apt-get install -y curl zip python2 g++ make gcc build-essential

# Download node + extract
RUN curl -LO https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz &&\
    tar -xvf node-v${NODE_VERSION}-linux-x64.tar.xz

# Update our PATH to include the node binary
ENV PATH=${PATH}:/node-v${NODE_VERSION}-linux-x64/bin

# Install Grails and Set Path
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
RUN curl -s "https://get.sdkman.io" | bash
RUN chmod a+x "$SDKMAN_DIR/bin/sdkman-init.sh"

# change timeout and max time based on your liking and internet speed
RUN set -x \
    && echo "sdkman_auto_answer=true" > $SDKMAN_DIR/etc/config \
    && echo "sdkman_auto_selfupdate=false" >> $SDKMAN_DIR/etc/config \
    && echo "sdkman_curl_connect_timeout=20" >> $SDKMAN_DIR/etc/config \
    && echo "sdkman_curl_max_time=0" >> $SDKMAN_DIR/etc/config \
    && echo "sdkman_insecure_ssl=false" >> $SDKMAN_DIR/etc/config

WORKDIR $SDKMAN_DIR
RUN [[ -s "$SDKMAN_DIR/bin/sdkman-init.sh" ]] && source "$SDKMAN_DIR/bin/sdkman-init.sh" && exec "$@"

RUN source /root/.bashrc

# install and set grails version
RUN bash -c "source $SDKMAN_DIR/bin/sdkman-init.sh && sdk install grails $GRAILS_VERSION"
RUN bash -c "source $SDKMAN_DIR/bin/sdkman-init.sh && sdk default grails $GRAILS_VERSION"

# set envs
ENV JAVA_HOME /usr/lib/jvm/zulu7-ca-amd64
ENV GRAILS_HOME /root/.sdkman/candidates/grails/current
ENV PATH $GRAILS_HOME/bin:$PATH
# Memory settings were required or else things would fail with OOM errors or stall forever
ENV GRAILS_OPTS -XX:MaxPermSize=8192m -Xmx8192M -XX:-UseSplitVerifier -Xverify:none

# Set the directory that an existing Grails app should be mounted into with a volume
RUN mkdir /app
WORKDIR /app

EXPOSE 8080

CMD ["grails"]

Updated openboxes-run.sh file

#!/bin/bash

# grails doesn't run without it for some reason
export GRAILS_OPTS="-XX:MaxPermSize=8192m -Xmx8192M -XX:-UseSplitVerifier -Xverify:none"

if [ ! -f /app/web-app/WEB-INF/applicationContext.xml ]; then
   echo "Forcing grails upgrade"
   grails upgrade --force --stacktrace
fi


npm cache clean --force
npm cache verify
npm i -g npm@6.14.6
npm config set engine-strict true
# npm update

# some dependencies don't get resolved on thier own
npm i --no-package-lock --legacy-peer-deps --force --verbose --stacktrace
grails run-app --stacktrace

# if you want to compile enable this and stop grails run-app
# grails -Dgrails.env=staging war

Running

  1. Make directory to hold openboxes stuff
  2. Clone https://github.com/openboxes/openboxes.git
  3. Clone https://github.com/openboxes/openboxes-docker.git
  4. You should have openboxes and openboxes-docker in same directory
  5. Copy dockerfile above and replace the contents of openboxes-docker/grails-java7/Dockerfile
  6. Copy openboxes-run.sh above and replace the contents of openboxes/docker/openboxes-run.sh
  7. cd to openboxes-docker
  8. Run docker compose up --build
  9. Let run until this error
  10. Ctrl-C to exit
  11. Run docker compose up
  12. Things should run, and you should get to a point where liquibase migrations start - that's good!
  13. Wait for things to finish, might take a while (10+ minutes)
  14. After migrations finish it shouldn't be too long until the site is ready to be accessed
  15. Navigate to localhost:8080/openboxes to use the tool

@JZafarr
Copy link

JZafarr commented Sep 24, 2023

Im stuck at Building React frontend and there is no output after that.
I didnt get the error message as mentioned above.

I used the Dockerfile and openboxes-run.sh by @ookjosh. I tried to CTRL+C and tried again but still gets stuck at "Building React frontend"

@ookjosh
Copy link

ookjosh commented Sep 27, 2023

@JZafarr Thank you so much for testing this, and I'm sorry that it didn't work. I was able to reproduce your issue, and have a fix that should at least move things forward for now. Apparently I had done something in openboxes before using the docker setup and that "fixed" things for me.

It requires node/npm on your host, so if that's not feasible please let me know. Hope it helps!

Short answer

On your host, do the following:

  1. Either clean clone openboxes, or sudo rm -rf node_modules if it exists at openboxes/node_modules.
  2. On host, cd openboxes
  3. On host (not in docker!) run npm i (make sure you're using node 14.x and npm 6.14.x)
  4. Now cd ../openboxes-docker
  5. docker compose up (using the changes in my post above to the dockerfile/sh files)
  6. This should get you past "Building React frontend" - it takes a bit to build, but should progress now
  7. The rest of the instructions above should be good to go.

Longer answer

npm has a feature (that has since been removed, apparently) where if it runs as root it will actually take on the GID/UID of the owner of the folder it is in. Since this docker compose setup works by mounting a directory on your filesystem into the container, npm uses your user info. However, this causes conflicts for when npm needs to build C++ dependencies because write permissions are borked.

I debugged this issue by getting a shell into the container via docker compose run grails /bin/bash, which allowed me to run the commands in openboxes-run.sh manually and track down errors, leading to the npm issue.

Thoughts on this setup

It's possible to have the container adopt the user's UID/GID instead of running as root, which has the advantage of not leaving root-owned files in the project folder. We'd have to do some reshuffling of the existing setup to move away from root-owned resources, but it shouldn't be too bad I think. This should also fix the npm error.

Otherwise, we could consider copying the openboxes assets into the image and running/installing there, but the downside to this is that the files are then not available for easy editing on the host. It would be more of a build/deploy step than anything.

@JZafarr
Copy link

JZafarr commented Sep 27, 2023

@ookjosh Thanks for the detailed response, I will try this and will let you know how it comes along.

@anudr01d
Copy link

anudr01d commented Oct 7, 2023

@ookjosh Thanks for the guide. Unfortunately, I still hit the "Building react frontend" error inspite of following your fix. I had to run "npm run bundle" outside the container (On the host) and comment out the same within _Events.groovy file to get this working.

@trbom5c
Copy link

trbom5c commented Dec 28, 2023

Is downgrading the host NODE version required to execute these commands?

@anudr01d I have to run npm run bundle --openssl-legacy-provider for this to execute on the host machine; but it fails with errors complaining that it does not support my environment.

image

Research points to having too high a node version for this to run properly.

Is downgrading node required?

@SujinIn
Copy link

SujinIn commented Jan 8, 2024

I tried.

sudo apt-get install curl -y
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -

--> I saw colorful warning..... I was scared, but I had courage.
DEPRECATION WARNING and SCRIPT DEPRECATION WARNING

sudo apt-get install nodejs -y

node -v

v14.21.3

npm -v

v6.14.18

And next, follow @ookjosh 's instruction.

React build finished
And next, next, next

`
openboxes-docker-db-1 | 2024-01-08T16:47:52.688999Z 21 [Note] Aborted connection 21 to db: 'openboxes' user: 'openboxes' host: '172.19.0.3' (Got an error reading communication packets)
openboxes-docker-grails-1 | Exception in thread "C3P0PooledConnectionPoolManager[identityToken->1bqsumbb01sw05aj1hc0scm|62cf4f82]-AdminTaskTimer"
openboxes-docker-grails-1 | Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "C3P0PooledConnectionPoolManager[identityToken->1bqsumbb01sw05aj1hc0scm|62cf4f82]-AdminTaskTimer"
openboxes-docker-grails-1 | Exception in thread "mysql-cj-abandoned-connection-cleanup"
openboxes-docker-grails-1 | Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "mysql-cj-abandoned-connection-cleanup"
openboxes-docker-grails-1 | 2024-01-08 16:49:11,494 [main] ERROR spring.ReloadAwareAutowireCapableBeanFactory - Destroy method on bean with name 'org.pih.warehouse.core.SynonymValidator' threw an exception
openboxes-docker-grails-1 | java.lang.OutOfMemoryError: PermGen space
openboxes-docker-grails-1 | 2024-01-08 17:15:22,152 [main] ERROR spring.ReloadAwareAutowireCapableBeanFactory - Destroy method on bean with name 'org.pih.warehouse.invoice.InvoiceListValidator' threw an exception
openboxes-docker-grails-1 | java.lang.OutOfMemoryError: PermGen space

`
and stucked.

Of course, I've updated Dockerfile and openboxes-run.sh file.
But there are...many java.lang.OutOfMemoryError: PermGen space messages.

Thank you everyone.

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

7 participants