Showing posts with label jelastic. Show all posts
Showing posts with label jelastic. Show all posts

Thursday, 7 October 2021

Running Payara Micro on Java 11 via GraalVM on Docker on Jelastic

Boy, that title was a mouth full.

Now if you want more information on Docker, you can check out reference [3]. Or if you're looking for Java 11 GraalVM Dockerimages suitable for Jelastic, you can check out [1] and [2].

This blog is more about the contents of the Dockerimage than Docker itself.

GraalVM

Well, I've been using Jelastic for a while now, and it suited my needs, until it didn't.

They provide GraalVM out of the box, but not the Java 11 version yet.

I was using a Payara Server image for Jelastic, and I had good results just installing GraalVM on the Image afterwards and run Payara using that, but I was looking for something a little more lean.

Sooo, in short, I used the GraalVM image used by Jelastic as a baseline in my Docker image (jelastic/javaengine:graalvm-21.0.0.2).

Then it was just install the JDK11 version of GraalVM and create my Image.

Less troublesome than I thought it would be.

Payara Micro

So Payara Micro is awesome. The way this differs from Microprofile, is that Microprofile contains only Microprofile and the Payara Micro basically seems to be a small Payara server run from the command line. It is based off the Payara Embedded Web release. See [4].

So there's basically two things:

  1. you run it from the command line using java and the payara-micro-5.2020.7.jar
  2. you provide a postboot file containing the settings

Example

Let's try an example.

The example basically runs a Payara Micro instance, with some wars deployed and a JDBC library for connecting to a database.

All configuration of the database connection is done using the afore mentioned postboot file.

Some notes on the postboot file.

  • I am not interested in Hazelcast, so I turned this off. The main result should be faster startup.
  • I added eclipselink.target-database to the jdbc string, otherwise the JDBC driver will identify itself as MariaDB driver, and it is unknown. You can immediately tell by the following error message in the log:

    Not able to detect platform for vendor name [MariaDB[10.4.20-MariaDB, 10]]. Defaulting to [org.eclipse.persistence.platform.database.DatabasePlatform]. The database dialect used may not match with the database you are using. Please explicitly provide a platform using property "eclipselink.target-database".

  • I also added a config property to it. Microprofile (which is included) has support for Configuration. And it's great!

Secure Socket Layer

There's a simple self signed SSL Certificate included in the Payara Micro, which works fine, unless, like me, you wish to use a genuine SSL Certificate.

The idea here is to expand on the command line (see above in run.sh) with SSL options, for example as follows:

  • -Djavax.net.ssl.trustStore="/home/jelastic/cacerts.jks"
  • -Djavax.net.ssl.keyStore="/home/jelastic/keystore.jks"
  • -Djavax.net.ssl.trustStorePassword="changeit"
  • -Djavax.net.ssl.keyStorePassword="changeit"

References

[1] Dockerhub - my jelastic graal with jdk 11 docker image
https://hub.docker.com/r/maartenl22/jelasticgraaljdk11
[2] Github - Docker file
https://github.com/maartenl/jelasticgraaljdk11
[3] MyBlog - Docker
https://randomthoughtsonjavaprogramming.blogspot.com/2021/06/docker.html
[4] Payara Micro Documentation
https://docs.payara.fish/community/docs/documentation/payara-micro/payara-micro.html
Releases - graalvm/graalvm-ce-builds
https://github.com/graalvm/graalvm-ce-builds/releases
How to install GraalVM on Linux with alternatives
https://gist.github.com/ricardozanini/fa65e485251913e1467837b1c5a8ed28
GraalVM - GraalVM Community Images
https://www.graalvm.org/docs/getting-started/container-images/
Github - graalvm-ce
https://github.com/orgs/graalvm/packages/container/package/graalvm-ce

Wednesday, 16 June 2021

Docker

$ sudo systemctl start docker

Configuration

I am on a low bandwith thing, so needed to add max-concurrent-uploads to the /etc/docket/daemon.json, otherwise I got connection timeouts. (default is 5)

{
  "experimental": false,
  "max-concurrent-uploads": 1,
  "data-root": "/mnt/docker" }

I've since moved the docker data directory ("data-root") to a separate mount ("/mnt/docker"), as it takes up a deal of space.

See reference 1.

Basics

docker pull dockerimageurl
downloads a particular image, probably from Docker Hub
docker images
can show you all the images the docker has at its disposal
docker container create
creates a new container based on an image
docker run --rm -i -t -p portext:portint dockerimageurl
start running a new container (-d is detached, -p is portmap, -i keep STDIN open even if not attached , -t allocates a pseudo-TTY, --rm removes container on exit ), basically does all of the previous steps if necessary

Administration

docker inspect dockerimageurl
shows low level information on the running container
docker exec <container-id> cat /data.txt
run a single command on the container, can be run as long as the master process (pid 1) is running
docker ls [-a]
seems to be exactly the same as ps
docker ps [-a]
list docker containers (-a for aboth started and stopped)
docker attach <the-container-id>
stttach to a running docker container with the ID from docker ps. Convenient if you've run it "detatched".
docker stop <the-container-id>
stop docker container with the ID from docker ps
docker rm <the-container-id>
remove docker container
docker rmi <the-image-id>
removes an image

Examples

Simply running an image can be done with:

docker run --rm -i -t -p 80:8080 -p 443:8181 --name jelasticgraaljdk17 jelastic/javaengine:graalvm-21.0.0.2

"--name" is a nice option to prevent docker from assigning meaningless auto-generated names to your containers.

It will help tremendously if we could look at how an original image was made. This is possible with the history command.

docker history jelastic/javaengine:graalvm-21.0.0.2

Add --no-trunc to show entire command lines.

For example in the example, it will show the following:

IMAGECREATEDCREATED BYSIZE
72627645230f12 days ago24.4MB
<missing> 12 days ago /bin/sh -c #(nop) WORKDIR /etc/init.d 0B
<missing> 12 days ago /bin/sh -c #(nop) LABEL actions=webAccess a… 0B
<missing> 12 days ago /bin/sh -c #(nop) EXPOSE 21 22 25 80 8080 0B

Added 443 8743 to the exposed ports in my new image.

Creating your own image

docker build
build a new container image based on a Dockerfile. (-t is tag)
docker commit c16378f943fe rhel-httpd:latest
docker login -u YOUR-USER-NAME
logging into the Docker hub
docker tag c16378f943fe YOUR-USER-NAME/name
tag your image appropriately before pushing it to the repo
docker push imagename:tag
pushes an image to a remote Docker repository. If you do not provide a tag, it will automatically become "latest".

Examples

cd ../graalvm
docker build -t maartenl22/jelasticgraaljdk11:latest -t maartenl22/jelasticgraaljdk11:v0.1 .
cd ../karchan
docker build -t maartenl22/karchan:latest -t maartenl22/karchan:v2.0.8 .

Check that this worked by running:

docker run --name graalvm --rm -i -t -p 8080:8080 -p 8743:8743 maartenl22/jelasticgraaljdk11:latest
docker run --name karchan --rm -i -t -p 8080:8080 -p 8743:8743 maartenl22/karchan:latest

Pushing your image to Docker Hub

Examples

docker build -t maartenl22/jelasticgraaljdk11 .
docker build -t maartenl22/karchan .
docker image ls

First do this, just to make sure:

docker logout
docker login
docker push maartenl22/jelasticgraaljdk11
docker push maartenl22/karchan

You should see both jelasticgraaljdk11 and registry-host:5000/maartenl22/jelasticgraaljdk11 listed.

You should see both karchan and registry-host:5000/maartenl22/karchan listed.

docker run --name karchan -cap-add=NET_ADMIN --rm -i -t -p 8080:8080 -p 8743:8743 jelasticgraaljdk11:latest

The -cap-add=NET_ADMIN is necessary to see the iptables configuration.

cd /home/jelastic
java -jar payara-micro-5.2021.1.jar --port 80 --sslport 443 jakartaee-8-project.war

Portainer

Portainer is a docker image containing a simple server that interfaces with the Docker deamon. With it you can get a good view of what Docker is running and what containers and images are available and all that.

Also attaching a terminal via de website is possible. Very nice.

docker volume create portainer_dataa
docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_dataa:/data portainer/portainer-ce

When starting it for the first time, and surfing to localhost:9000, you can add an administrator user.

It works great to get a good overview about what's going on.

Hello, world.

References

[1] GuguWeb - HOW TO MOVE DOCKER DATA DIRECTORY TO ANOTHER LOCATION ON UBUNTU
https://www.guguweb.com/2019/02/07/how-to-move-docker-data-directory-to-another-location-on-ubuntu/
Jelastic - Build software stack container image for private PaaS
https://jelastic.com/blog/build-software-stack-container-image-private-paas/
Jelastic - Building custom containers
https://docs.jelastic.com/building-custom-container/
Docker - Custom container deployment
https://docs.jelastic.com/custom-containers-deployment/
Docker - Installing fedora
https://docs.docker.com/engine/install/fedora/
Docker - Reference manuals
https://docs.docker.com/reference/
Portainer
https://www.portainer.io/
Youtube - Intro to Docker [with Java Examples]
https://youtu.be/FzwIs2jMESM
Dockerhub - my jelastic graal with jdk 11 docker image
https://hub.docker.com/r/maartenl22/jelasticgraaljdk11
Github - Docker file
https://github.com/maartenl/jelasticgraaljdk11

Thursday, 29 April 2021

Jelastic CLI

Just some notes of mine on how to install Jelastic command line tools and how to connect to your Jelastic provider1 2.

A little disappointed that installing the command line tools doesn't let me know that it "succeeded". It just returns my command prompt, with no indication what it did.

I thought it had quit unexpectedly.

The first call to the API will require authentication.

As I have enabled two-factor authentication, it's best if I create a personal access token3.

Success!

The absolute main reason to use it, I think, is the ability to move my static IP address of a Jelastic Node to another Node4, creating seamless upgrades.

I've tried it, and it's awesome.

I don't even have to explain how it works here. It's simple and the guide is fine.

References

[1] Payara platform and Jelastic PAAS
[2] Jelastic - Jelastic CLI Overview
https://docs.jelastic.com/cli/
[3] Jelastic - Personal Access Tokens
https://docs.jelastic.com/personal-access-tokens/
[4] Jelastic - CLI Tutorial: Public IPs (External Addresses) Swap
https://docs.jelastic.com/cli-ip-swap/

Thursday, 15 October 2020

Running Java in the Cloud - Jelastic

So I decided to try running some of my stuff in the cloud, instead of having to hire a Virtual Machine type thing.

In order to have to limit my changes, I decided to go with Jelastic1.

I decided to try out hosting provider EAPPS2, because they are one of the providers of PaaS3 with Jelastic4.

They suggested I'd read up on [5].

Some requirements I'd like:

  1. must support Let's Encrypt certificates
  2. access to the filesystem would be nice (I'm keeping logfiles)
  3. A Mysql/MariaDB database is a must
  4. Need to be able to upload an existing database
  5. Easily create backups.
  6. Must support websockets
  7. Support DNS for custom domains.

It supports all of those, and relieves me of some server administration and maintenance.

References

[1] Jelastic
https://jelastic.com/
[2] EAPPS HOSTING - Leading Managed Hosting Provider
https://www.eapps.com/
[4] eApps PaaS, Powered by Jelastic
https://www.eapps.com/platforms/paas.php
[3] Wikipedia - PaaS
https://en.wikipedia.org/wiki/Platform_as_a_service
[5] Getting Started with eApps Platform as a Service (PaaS)
https://support.eapps.com/index.php?/Knowledgebase/Article/View/535/79/getting-started-with-eapps-paas-platform-as-a-service
Jelastic Blog - JDBC Connection Pool for GlassFish and Payara Java Application Servers
https://jelastic.com/blog/jdbc-connection-pool-java-glassfish-payara/
Jelastic Blog - Free Let’s Encrypt SSL Certificates: Out-of-Box Integration with the Most Popular Software Stacks
https://jelastic.com/blog/free-ssl-certificates-with-lets-encrypt/
Jelastic - Import and Export Dump Files to MySQL/MariaDB
https://docs.jelastic.com/dump-import-export-to-mysql/
Jelastic - Storing Data in Local Filesystem
https://docs.jelastic.com/local-filesystem-storage/
DockerHub - jelastic/payara
https://hub.docker.com/r/jelastic/payara/
Jelastic - Sending e-mail from your jelastic environment
https://support.eapps.com/index.php?/Knowledgebase/Article/View/535/79/getting-started-with-eapps-paas-platform-as-a-service#sending-e-mail-from-your-jelastic-environment
Jelastic Developers Center - WebSockets Support for Java
https://docs.jelastic.com/websockets-java/
Jelastic Developers Center - Custom Domain Name
https://docs.jelastic.com/custom-domains/