Forget Kubernetes for now :)

My recipe is using a multi-stage build. Very crudely:

FROM maven as maven
# build your webapp into a .war
mvn clean install

FROM tomcat
COPY --from=maven /webapp/target/ROOT webapps/ROOT/

It copies the whole folder from the build directory rather than the .war file.
Here is an example:
https://github.com/AtomGraph/LinkedDataHub/blob/master/Dockerfile

It does not use tomcat image directly but rather an intermediary image
which adds config as ENV capabilities as well as LetsEncrypt
certificates:
https://hub.docker.com/r/atomgraph/letsencrypt-tomcat/

You might also want to take a look at the entrypoint script which is a
bit more involved:
https://github.com/AtomGraph/LinkedDataHub/blob/master/platform/entrypoint.sh

Look at the container as a large function. Minimize the number of
inputs to it - generate all the configs that can be generated and
execute the init actions within Dockerfile and/or entrypoint. Mount
the rest from host as volumes, under Tomcat's webapps/ROOT (assuming
you're Dockerizing one webapp).

Martynas
atomgraph.com

On Thu, Jan 9, 2020 at 8:32 PM Christopher Schultz
<ch...@christopherschultz.net> wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> Pater,
>
> On 1/9/20 12:39 PM, logo wrote:
> >> Am 09.01.2020 um 17:51 schrieb Alex K <rightkickt...@gmail.com>:
> >>
> >> Hi all,
> >>
> >> I have two .war files that when deployed at a plain Debian 9 VM
> >> are working fine. I have prepared a docker file so as to deploy
> >> the same apps within a docker container and for some reason one
> >> of the apps is not loading due to some error.
> >>
> >> Dockerfile: FROM debian:latest
> >
> > Why not using any of the different flavored tomcat images?
> >
> > https://hub.docker.com/_/tomcat <https://hub.docker.com/_/tomcat>
> >
> > You get a working jdk (oracle, adopt, openjdk) and don’t have to
> > build the system yourself. That may help to get the base running
> > and then copy your file to the correct spots.
>
> If you've got experience with Docker, I'd love for someone to put
> together a post/presenation/whatever which addresses this question:
>
> I've got an application that I deploy to Tomcat on a traditional
> server; How do I Dockerize that?
>
> Specifically, I'd like more than just "well, docker-compose with your
> WAR file and put it in the right place" because we all know that there
> are plenty of configuration files, etc. that don't work well with a
> WAR file, etc.
>
> So maybe this bleeds into "well, if you want to use Docker, maybe you
> want to consider Kubernetes for configuration" and then explain how
> you might move some of your server/application configuration into
> Kubernetes (or similar). I'd like to understand how to package-up
> things like this to be able to eventually use something like AWS's
> auto-scaling.
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/
>
> iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl4Xf6sACgkQHPApP6U8
> pFgobg//Zf5fQ5RqqNDYRDk8KFuS7QWmsZWxUez/waeEbrLW0z/iBRYaIDf63dDs
> G6/XOPAKov5K4jWxLxTeUY/GUVklwdqy8mGnQJwEmBOlFrMqidfrYZEbx4b6Us1o
> /GiAch2QUFhflaZ7DzSjxLYosMdReiQRl4PXnLVxNUQ7jB7aRaYRMwXgjCJGc66b
> PXJSUamYhngIlV4ZYB23ACJsbUlaacsyiYdXOJNSuip/xb8atz547KuGT7shCT0P
> QqJMNDD91KHWBtgrldkO9pb6zYMpwCUxf5PE9jpgk6U6MDlXeXF+HGEnYY6PFxwV
> kJfsPt2JUIC8Coo7ydkboxUgSQ16xvV6/PvhAdUGiaadS+WF4ZullveqSyNVHBQw
> dQI563oQYZ1qfh8zcHeZdsb7TLIaVh9Vx2Vn/+XN1bA1tcvjJx+Pz0fEHjtTy8Q+
> JW2nLIV2ZdbpsdHi0FjdIWIXscg+EyVMUiPx+qmpVyFA3Al7GWLc1h7yQic+hsuT
> oscRQf2crbu2tpPBBRP5YodtcAtOOvxbbRsQnALxKuBhBDmFzdl4taPTXlko6Kqc
> b1C/onqwrDlVPKwySPWFU43rTCLImD0L7eGCDxIzDX5z/HbGahtvYxKXf/Jpg7Sl
> lZuGlyhIIgRoWZF3utUsI11YjRsmRFme0EtfpMdBz/Xb4v/9YeU=
> =PK8y
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to