You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Hans Bakker <h....@antwebsystems.com> on 2018/02/21 05:03:39 UTC

quick docker image startup?

Good day!

i am trying to create a docker image of the new ofbiz using gradle.

And obviously i want a quick startup time.

So i run all the gradle build tasks offline, copy the result in a docker 
image and install it in a docker environment.

Then as normal run ./gradlew ofbiz  as the startup command.

Then because the gradle cache is not there gradle rebuids. Copying the 
gradle cache into the docker image is no option, because it gets 
substantial bigger.

How to start the system assuming the build was successful and no rebuild 
is required?

-- 

Regards,

Hans Bakker
CEO, http://antwebsystems.com

Re: quick docker image startup?

Posted by Hans Bakker <h....@antwebsystems.com>.
Taher, thanks for your help, in the future i probably will write an 
article how to use gradle ofbiz with docker in production.

-- 

Regards,

Hans Bakker
CEO, http://antwebsystems.com

On 22/02/18 13:20, Taher Alkhateeb wrote:
> If you want my opinion, just download the cache and save it to your image.
> Who cares about size, this is an end product image, nothing to be used in a
> chain.
> 
> So just have a gradlew command to build and load inside your Dockerfile.
> Remember the cache is simply replacement to the old jars that existed with
> the code base. This is now how most modern software works and it is
> becoming less and less common for projects to carry dependencies in the
> code base.
> 
> Now regarding your comment about username and server, there are many tweaks
> you can make to gradle. Check the command line documentation [1]. For
> example you can relocate the cache location using the --gradle-user-home
> flag. Also generally in docker things are very much dependent on userne,
> that's a docker thing, not a gradle thing.
> 
> HTH
> 
> [1] https://docs.gradle.org/current/userguide/command_line_interface.html
> 
> On Feb 22, 2018 6:23 AM, "Hans Bakker" <h....@antwebsystems.com> wrote:
> 
> Hi Taher, thanks for your support.
> 
> My problem was caused by the unavailability of the gradle cache by using
> the java -jar command. This means that his cache is part of the system
> execution and is not just used to build the system. I also found it cannot
> be created offline, it looks like it is dependent on the username and
> server?
> 
> I have the docker image working now according your recommendations:
> 
> Within the docker container I run the ofbiz system as user root and persist
> the directory /root/.gradle
> 
> This means however that the first startup of the container requires the
> full download of all dependencies.
> 
> Conclusion:
> 1. it is not possible to create an ofbiz production system locally and
> install it in a production environment. It needs to be build in place of
> production.
> 
> 2. The gradle cache is part of the system code, the system will not run
> without it.
> 
> It would be much better if we could build the system offline, create the
> docker container which should run without rebuilding and the gradle cache.
> This is what a docker container is used for?
> 
> 

-- 

Regards,

Hans Bakker
CEO, http://antwebsystems.com

Re: quick docker image startup?

Posted by Taher Alkhateeb <sl...@gmail.com>.
If you want my opinion, just download the cache and save it to your image.
Who cares about size, this is an end product image, nothing to be used in a
chain.

So just have a gradlew command to build and load inside your Dockerfile.
Remember the cache is simply replacement to the old jars that existed with
the code base. This is now how most modern software works and it is
becoming less and less common for projects to carry dependencies in the
code base.

Now regarding your comment about username and server, there are many tweaks
you can make to gradle. Check the command line documentation [1]. For
example you can relocate the cache location using the --gradle-user-home
flag. Also generally in docker things are very much dependent on userne,
that's a docker thing, not a gradle thing.

HTH

[1] https://docs.gradle.org/current/userguide/command_line_interface.html

On Feb 22, 2018 6:23 AM, "Hans Bakker" <h....@antwebsystems.com> wrote:

Hi Taher, thanks for your support.

My problem was caused by the unavailability of the gradle cache by using
the java -jar command. This means that his cache is part of the system
execution and is not just used to build the system. I also found it cannot
be created offline, it looks like it is dependent on the username and
server?

I have the docker image working now according your recommendations:

Within the docker container I run the ofbiz system as user root and persist
the directory /root/.gradle

This means however that the first startup of the container requires the
full download of all dependencies.

Conclusion:
1. it is not possible to create an ofbiz production system locally and
install it in a production environment. It needs to be build in place of
production.

2. The gradle cache is part of the system code, the system will not run
without it.

It would be much better if we could build the system offline, create the
docker container which should run without rebuilding and the gradle cache.
This is what a docker container is used for?


-- 

Regards,

Hans Bakker
CEO, http://antwebsystems.com


On 21/02/18 20:34, Taher Alkhateeb wrote:

> Oh .. that would be hard to debug without further analysis. Essentially
> Java is not seeing libraries in the classpath. The classpath is defined
> _inside_ the jar file with pointers to where the gradle cache is located.
>
> So it could be many things, maybe you did not make a first run with gradle
> to download the cache, or maybe you have different users inside the
> container each with their own cache directory. Another possibility is that
> you mounted a volume on top of the downloaded cache.
>
> On Feb 21, 2018 4:22 PM, "Hans Bakker" <h....@antwebsystems.com> wrote:
>
> Thanks Taher, for the extended reply.
>
> currently I have tried the most simple one:
> java -jar build/libs/ofbiz.jar
>
> this works outside the docker image, however within the running container
> it gives the error:
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/commons/cli/ParseException
>          at org.apache.ofbiz.base.start.Start.main(Start.java:60)
> Caused by: java.lang.ClassNotFoundException:
> org.apache.commons.cli.ParseEx
> ception
>          at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
>          at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
>          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
>          at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
>          ... 1 more
>
> perhaps you have a suggestion for me?
>
> thanks again for your help.
> Regards,
> Hans
>
>
> On 21/02/18 17:56, Taher Alkhateeb wrote:
>
> Oh I just remembered something else you might want to do. You can create a
>> volume for the cache, this way you wait for the download only the first
>> time you instantiate the image and subsequent container instantiations
>> would not need to download anything
>>
>> On Feb 21, 2018 9:55 AM, "Taher Alkhateeb" <sl...@gmail.com>
>> wrote:
>>
>> The image has to get larger, there is no way around that. Either you
>> repopulate the cache or save a bigger image. OFBiz will not work without
>> its libraries just like in the ant days.
>>
>> For me I have a big OFBiz image because I don't care about size as much as
>> I do about startup time.
>>
>> Now your question was how to start without a rebuild. You can either:
>>
>> 1- in build.gradle go to the method createOfbizCommandTask and remove
>> "dependsOn build"
>> OR
>> 2- run java -jar build/libs/ofbiz.jar
>>
>> On Feb 21, 2018 8:03 AM, "Hans Bakker" <h....@antwebsystems.com>
>> wrote:
>>
>> Good day!
>>
>> i am trying to create a docker image of the new ofbiz using gradle.
>>
>> And obviously i want a quick startup time.
>>
>> So i run all the gradle build tasks offline, copy the result in a docker
>> image and install it in a docker environment.
>>
>> Then as normal run ./gradlew ofbiz  as the startup command.
>>
>> Then because the gradle cache is not there gradle rebuids. Copying the
>> gradle cache into the docker image is no option, because it gets
>> substantial bigger.
>>
>> How to start the system assuming the build was successful and no rebuild
>> is
>> required?
>>
>>
>>

Re: quick docker image startup?

Posted by Hans Bakker <h....@antwebsystems.com>.
Hi Taher, thanks for your support.

My problem was caused by the unavailability of the gradle cache by using 
the java -jar command. This means that his cache is part of the system 
execution and is not just used to build the system. I also found it 
cannot be created offline, it looks like it is dependent on the username 
and server?

I have the docker image working now according your recommendations:

Within the docker container I run the ofbiz system as user root and 
persist the directory /root/.gradle

This means however that the first startup of the container requires the 
full download of all dependencies.

Conclusion:
1. it is not possible to create an ofbiz production system locally and 
install it in a production environment. It needs to be build in place of 
production.

2. The gradle cache is part of the system code, the system will not run 
without it.

It would be much better if we could build the system offline, create the 
docker container which should run without rebuilding and the gradle 
cache. This is what a docker container is used for?

-- 

Regards,

Hans Bakker
CEO, http://antwebsystems.com


On 21/02/18 20:34, Taher Alkhateeb wrote:
> Oh .. that would be hard to debug without further analysis. Essentially
> Java is not seeing libraries in the classpath. The classpath is defined
> _inside_ the jar file with pointers to where the gradle cache is located.
> 
> So it could be many things, maybe you did not make a first run with gradle
> to download the cache, or maybe you have different users inside the
> container each with their own cache directory. Another possibility is that
> you mounted a volume on top of the downloaded cache.
> 
> On Feb 21, 2018 4:22 PM, "Hans Bakker" <h....@antwebsystems.com> wrote:
> 
> Thanks Taher, for the extended reply.
> 
> currently I have tried the most simple one:
> java -jar build/libs/ofbiz.jar
> 
> this works outside the docker image, however within the running container
> it gives the error:
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/commons/cli/ParseException
>          at org.apache.ofbiz.base.start.Start.main(Start.java:60)
> Caused by: java.lang.ClassNotFoundException: org.apache.commons.cli.ParseEx
> ception
>          at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
>          at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
>          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
>          at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
>          ... 1 more
> 
> perhaps you have a suggestion for me?
> 
> thanks again for your help.
> Regards,
> Hans
> 
> 
> On 21/02/18 17:56, Taher Alkhateeb wrote:
> 
>> Oh I just remembered something else you might want to do. You can create a
>> volume for the cache, this way you wait for the download only the first
>> time you instantiate the image and subsequent container instantiations
>> would not need to download anything
>>
>> On Feb 21, 2018 9:55 AM, "Taher Alkhateeb" <sl...@gmail.com>
>> wrote:
>>
>> The image has to get larger, there is no way around that. Either you
>> repopulate the cache or save a bigger image. OFBiz will not work without
>> its libraries just like in the ant days.
>>
>> For me I have a big OFBiz image because I don't care about size as much as
>> I do about startup time.
>>
>> Now your question was how to start without a rebuild. You can either:
>>
>> 1- in build.gradle go to the method createOfbizCommandTask and remove
>> "dependsOn build"
>> OR
>> 2- run java -jar build/libs/ofbiz.jar
>>
>> On Feb 21, 2018 8:03 AM, "Hans Bakker" <h....@antwebsystems.com> wrote:
>>
>> Good day!
>>
>> i am trying to create a docker image of the new ofbiz using gradle.
>>
>> And obviously i want a quick startup time.
>>
>> So i run all the gradle build tasks offline, copy the result in a docker
>> image and install it in a docker environment.
>>
>> Then as normal run ./gradlew ofbiz  as the startup command.
>>
>> Then because the gradle cache is not there gradle rebuids. Copying the
>> gradle cache into the docker image is no option, because it gets
>> substantial bigger.
>>
>> How to start the system assuming the build was successful and no rebuild is
>> required?
>>
>>


Re: quick docker image startup?

Posted by Taher Alkhateeb <sl...@gmail.com>.
Oh .. that would be hard to debug without further analysis. Essentially
Java is not seeing libraries in the classpath. The classpath is defined
_inside_ the jar file with pointers to where the gradle cache is located.

So it could be many things, maybe you did not make a first run with gradle
to download the cache, or maybe you have different users inside the
container each with their own cache directory. Another possibility is that
you mounted a volume on top of the downloaded cache.

On Feb 21, 2018 4:22 PM, "Hans Bakker" <h....@antwebsystems.com> wrote:

Thanks Taher, for the extended reply.

currently I have tried the most simple one:
java -jar build/libs/ofbiz.jar

this works outside the docker image, however within the running container
it gives the error:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/commons/cli/ParseException
        at org.apache.ofbiz.base.start.Start.main(Start.java:60)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.cli.ParseEx
ception
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 1 more

perhaps you have a suggestion for me?

thanks again for your help.
Regards,
Hans


On 21/02/18 17:56, Taher Alkhateeb wrote:

> Oh I just remembered something else you might want to do. You can create a
> volume for the cache, this way you wait for the download only the first
> time you instantiate the image and subsequent container instantiations
> would not need to download anything
>
> On Feb 21, 2018 9:55 AM, "Taher Alkhateeb" <sl...@gmail.com>
> wrote:
>
> The image has to get larger, there is no way around that. Either you
> repopulate the cache or save a bigger image. OFBiz will not work without
> its libraries just like in the ant days.
>
> For me I have a big OFBiz image because I don't care about size as much as
> I do about startup time.
>
> Now your question was how to start without a rebuild. You can either:
>
> 1- in build.gradle go to the method createOfbizCommandTask and remove
> "dependsOn build"
> OR
> 2- run java -jar build/libs/ofbiz.jar
>
> On Feb 21, 2018 8:03 AM, "Hans Bakker" <h....@antwebsystems.com> wrote:
>
> Good day!
>
> i am trying to create a docker image of the new ofbiz using gradle.
>
> And obviously i want a quick startup time.
>
> So i run all the gradle build tasks offline, copy the result in a docker
> image and install it in a docker environment.
>
> Then as normal run ./gradlew ofbiz  as the startup command.
>
> Then because the gradle cache is not there gradle rebuids. Copying the
> gradle cache into the docker image is no option, because it gets
> substantial bigger.
>
> How to start the system assuming the build was successful and no rebuild is
> required?
>
>
-- 

Regards,

Hans Bakker
CEO, http://antwebsystems.com

Re: quick docker image startup?

Posted by Hans Bakker <h....@antwebsystems.com>.
Thanks Taher, for the extended reply.

currently I have tried the most simple one:
java -jar build/libs/ofbiz.jar

this works outside the docker image, however within the running 
container it gives the error:
Exception in thread "main" java.lang.NoClassDefFoundError: 
org/apache/commons/cli/ParseException
	at org.apache.ofbiz.base.start.Start.main(Start.java:60)
Caused by: java.lang.ClassNotFoundException: 
org.apache.commons.cli.ParseException
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 1 more

perhaps you have a suggestion for me?

thanks again for your help.
Regards,
Hans

On 21/02/18 17:56, Taher Alkhateeb wrote:
> Oh I just remembered something else you might want to do. You can create a
> volume for the cache, this way you wait for the download only the first
> time you instantiate the image and subsequent container instantiations
> would not need to download anything
> 
> On Feb 21, 2018 9:55 AM, "Taher Alkhateeb" <sl...@gmail.com>
> wrote:
> 
> The image has to get larger, there is no way around that. Either you
> repopulate the cache or save a bigger image. OFBiz will not work without
> its libraries just like in the ant days.
> 
> For me I have a big OFBiz image because I don't care about size as much as
> I do about startup time.
> 
> Now your question was how to start without a rebuild. You can either:
> 
> 1- in build.gradle go to the method createOfbizCommandTask and remove
> "dependsOn build"
> OR
> 2- run java -jar build/libs/ofbiz.jar
> 
> On Feb 21, 2018 8:03 AM, "Hans Bakker" <h....@antwebsystems.com> wrote:
> 
> Good day!
> 
> i am trying to create a docker image of the new ofbiz using gradle.
> 
> And obviously i want a quick startup time.
> 
> So i run all the gradle build tasks offline, copy the result in a docker
> image and install it in a docker environment.
> 
> Then as normal run ./gradlew ofbiz  as the startup command.
> 
> Then because the gradle cache is not there gradle rebuids. Copying the
> gradle cache into the docker image is no option, because it gets
> substantial bigger.
> 
> How to start the system assuming the build was successful and no rebuild is
> required?
> 

-- 

Regards,

Hans Bakker
CEO, http://antwebsystems.com

Re: quick docker image startup?

Posted by Taher Alkhateeb <sl...@gmail.com>.
Oh I just remembered something else you might want to do. You can create a
volume for the cache, this way you wait for the download only the first
time you instantiate the image and subsequent container instantiations
would not need to download anything

On Feb 21, 2018 9:55 AM, "Taher Alkhateeb" <sl...@gmail.com>
wrote:

The image has to get larger, there is no way around that. Either you
repopulate the cache or save a bigger image. OFBiz will not work without
its libraries just like in the ant days.

For me I have a big OFBiz image because I don't care about size as much as
I do about startup time.

Now your question was how to start without a rebuild. You can either:

1- in build.gradle go to the method createOfbizCommandTask and remove
"dependsOn build"
OR
2- run java -jar build/libs/ofbiz.jar

On Feb 21, 2018 8:03 AM, "Hans Bakker" <h....@antwebsystems.com> wrote:

Good day!

i am trying to create a docker image of the new ofbiz using gradle.

And obviously i want a quick startup time.

So i run all the gradle build tasks offline, copy the result in a docker
image and install it in a docker environment.

Then as normal run ./gradlew ofbiz  as the startup command.

Then because the gradle cache is not there gradle rebuids. Copying the
gradle cache into the docker image is no option, because it gets
substantial bigger.

How to start the system assuming the build was successful and no rebuild is
required?

-- 

Regards,

Hans Bakker
CEO, http://antwebsystems.com

Re: quick docker image startup?

Posted by Taher Alkhateeb <sl...@gmail.com>.
The image has to get larger, there is no way around that. Either you
repopulate the cache or save a bigger image. OFBiz will not work without
its libraries just like in the ant days.

For me I have a big OFBiz image because I don't care about size as much as
I do about startup time.

Now your question was how to start without a rebuild. You can either:

1- in build.gradle go to the method createOfbizCommandTask and remove
"dependsOn build"
OR
2- run java -jar build/libs/ofbiz.jar

On Feb 21, 2018 8:03 AM, "Hans Bakker" <h....@antwebsystems.com> wrote:

Good day!

i am trying to create a docker image of the new ofbiz using gradle.

And obviously i want a quick startup time.

So i run all the gradle build tasks offline, copy the result in a docker
image and install it in a docker environment.

Then as normal run ./gradlew ofbiz  as the startup command.

Then because the gradle cache is not there gradle rebuids. Copying the
gradle cache into the docker image is no option, because it gets
substantial bigger.

How to start the system assuming the build was successful and no rebuild is
required?

-- 

Regards,

Hans Bakker
CEO, http://antwebsystems.com