Thursday, October 20, 2022

Docker UBI RedHat image

HOWTO 

 

Search for image

Pastdave@dave ~]$ docker search registry.access.redhat.com/ubi
NAME                      DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
ubi8/go-toolset           Platform for building and running Go 1.11.5 …   0                    
ubi9/go-toolset           rhcc_registry.access.redhat.com_ubi9/go-tool…   0                    
ubi7                      The Universal Base Image is designed and eng…   0                    
ubi9-beta/ubi             Provides the latest release of Red Hat Unive…   0                    
ubi8/openjdk-8-runtime    OpenJDK 1.8 runtime-only image on Red Hat Un…   0                    
ubi8/openjdk-11-runtime   OpenJDK 11 runtime-only image on Red Hat Uni…   0                    
ubi8/openjdk-17-runtime   OpenJDK 17 runtime-only image on Red Hat Uni…   0                    
ubi7/ubi-minimal          The Universal Base Image Init is designed to…   0                    
ubi7/ubi-init             The Universal Base Image Init is designed to…   0                    
ubi8-minimal              The Universal Base Image Minimal is a stripp…   0                    
ubi7-minimal              The Universal Base Image Minimal is a stripp…   0                    
ubi8/ubi-micro            Provides the latest release of Micro Univers…   0                    
ubi9-beta/ubi-minimal     Provides the latest release of the Minimal R…   0                    
ubi9/ubi-init             rhcc_registry.access.redhat.com_ubi9/ubi-init   0                    
ubi9-init                 rhcc_registry.access.redhat.com_ubi9-init       0                    
ubi9-micro                rhcc_registry.access.redhat.com_ubi9-micro      0                    
ubi7/ubi                  The Universal Base Image is designed and eng…   0                    
ubi8/ubi                  Provides the latest release of the Red Hat U…   0                    
ubi8                      The Universal Base Image is designed and eng…   0                    
ubi9/ubi                  rhcc_registry.access.redhat.com_ubi9/ubi        0                    
ubi9                      rhcc_registry.access.redhat.com_ubi9            0                    
ubi8/ubi-minimal          Provides the latest release of the Minimal R…   0                    
ubi8/ubi-init             Provides the latest release of the Red Hat U…   0                    
ubi8-init                 The Universal Base Image Init is designed to…   0                    
ubi7-init                 The Universal Base Image Init is designed to…   0                    
ubi8-micro                Provides the latest release of Micro Univers…   0                    
ubi9-beta/ubi-init        Provides the latest release of the Red Hat U…   0                    
ubi9-beta/ubi-micro       Provides the latest release of Micro Univers…   0                    
ubi9/ubi-minimal          rhcc_registry.access.redhat.com_ubi9/ubi-min…   0                    
ubi9/ubi-micro            rhcc_registry.access.redhat.com_ubi9/ubi-mic…   0                    
ubi9-minimal              rhcc_registry.access.redhat.com_ubi9-minimal    0                    
ubi7/php-72               Apache 2.4 with PHP 7.2                         0                    
ubi8/php-72               Platform for building and running PHP 7.2 ap…   0                    
ubi8/s2i-core             Base image which allows using of source-to-i…   0                    
ubi8/s2i-base             Base image with essential libraries and tool…   0                    
ubi8/python-27            Platform for building and running Python 2.7…   0                    
ubi8/python-36            Platform for building and running Python 3.6…   0                    
ubi7/nodejs-8             Platform for building and running Node.js 8 …   0                    
ubi7/ruby-25              Platform for building and running Ruby 2.5 a…   0                    
ubi7/python-27            Python 2.7 platform for building and running…   0                    
ubi8/dotnet-21            .NET Core 2.1 SDK and Runtime on RHEL 8         0                    
ubi7/go-toolset           Platform for building and running Go Applica…   0                    
ubi8/ruby-26              Platform for building and running Ruby 2.6 a…   0                    
ubi8/nodejs-12            Platform for building and running Node.js 12…   0                    
ubi8/php-73               Platform for building and running PHP 7.3 ap…   0                    
ubi7/nodejs-10            Platform for building and running Node.js 10…   0                    
ubi8/dotnet-30            .NET Core 3.0 SDK and Runtime on RHEL 8         0                    
ubi7/php-73               Platform for building and running PHP 7.3 ap…   0                    
ubi7/nodejs-12            Platform for building and running Node.js 12…   0                    
ubi8/openjdk-8            Source To Image (S2I) image for Red Hat Open…   0                    
ubi8/python-38            Platform for building and running Python 3.8…   0                    
ubi8/dotnet-31-runtime    .NET Core 3.1 runtime only on RHEL 8            0                    
ubi8/nginx-118            Platform for running nginx 1.18 or building …   0                    
ubi8/ruby-27              Platform for building and running Ruby 2.7 a…   0                    
ubi8/dotnet-50            .NET 5.0 SDK and Runtime on RHEL 8              0                    
ubi7/nginx-118            Platform for running nginx 1.18 or building …   0                    
ubi8/pause                Podman pod infrastructure container             0                    
ubi8/skopeo               Containerized version of Skopeo                 0                    
ubi8/python-39            Platform for building and running Python 3.9…   0                    
ubi8/httpd-24             Platform for running Apache httpd 2.4 or bui…   0                    
ubi7/ruby-30              Ruby 3.0                                        0                    
ubi8/podman               Containerized version of Podman                 0                    
ubi7/nginx-120            Platform for running nginx 1.20 or building …   0                    
ubi8/openjdk-17           Source To Image (S2I) image for Red Hat Open…   0                    
ubi8/php-80               rhcc_registry.access.redhat.com_ubi8/php-80     0                    
ubi8/perl-532             rhcc_registry.access.redhat.com_ubi8/perl-532   0                    
ubi8/dotnet-21-runtime    Provides the latest release of Red Hat Enter…   0                    
ubi8/perl-526             Platform for building and running Perl 5.26 …   0                    
ubi8/nodejs-10            Platform for building and running Node.js 10…   0                    
ubi8/ruby-25              Platform for building and running Ruby 2.5 a…   0                    
ubi7/python-36            Platform for building and running Python 3.6…   0                    
ubi7/s2i-core             Base image which allows using of source-to-i…   0                    
ubi7/s2i-base             Base image with essential libraries and tool…   0                    
ubi8/dotnet-30-runtime    .NET Core 3.0 runtime only on RHEL 8            0                    
ubi7/ruby-26              Platform for building and running Ruby 2.5 a…   0                    
ubi8/openjdk-11           Source To Image (S2I) image for Red Hat Open…   0                    
ubi8/dotnet-31            .NET Core 3.1 SDK and Runtime on RHEL 8         0                    
ubi7/ruby-27              Platform for building and running Ruby 2.7 a…   0                    
ubi7/python-38            Python 3.8 platform for building and running…   0                    
ubi8/nodejs-14            Platform for building and running Node.js 14…   0                    
ubi8/perl-530             Platform for building and running Perl 5.26 …   0                    
ubi8/php-74               Platform for building and running PHP 7.4 ap…   0                    
ubi8/dotnet-50-runtime    .NET 5.0 runtime only on RHEL 8                 0                    
ubi7/nodejs-14            Platform for building and running Node.js 14…   0                    
ubi8/buildah              Containerized version of Buildah                0                    
ubi8/nodejs-14-minimal    Minimal image for running Node.js 14 applica…   0                    
ubi8/toolbox              Toolbox containerized shell image based in U…   0                    
ubi8/ruby-30              Platform for building and running Ruby 3.0 a…   0                    
ubi8/nginx-120            Platform for running nginx 1.20 or building …   0                    
ubi8/nodejs-16            Platform for building and running Node.js 16…   0                    
ubi8/nodejs-16-minimal    Minimal image for running Node.js 16 applica…   0                    
ubi8/dotnet-60-runtime    .NET 6.0 runtime only on RHEL 8                 0                    
ubi8/dotnet-60            .NET 6.0 SDK and Runtime on RHEL 8              0                    
ubi8/openssl              rhcc_registry.access.redhat.com_ubi8/openssl    0                    
ubi9-beta/toolbox         Toolbox containerized shell image based in U…   0                    
rhel8/toolbox             Toolbox containerized shell image based in U…   0                    
rhel9-beta/toolbox        Toolbox containerized shell image based in U…   0                    
ubi9/toolbox              rhcc_registry.access.redhat.com_ubi9/toolbox    0                    
ubi9/openjdk-11-runtime   rhcc_registry.access.redhat.com_ubi9/openjdk…   0                    
ubi9/openjdk-17-runtime   rhcc_registry.access.redhat.com_ubi9/openjdk…   0                    
e your text here.

 

Create container 

dave@dave ~]$ docker run -it --name  ubi-test registry.access.redhat.com/ubi8/ubi bash
Unable to find image 'registry.access.redhat.com/ubi8/ubi:latest' locally
latest: Pulling from ubi8/ubi
7985264c26f7: Pull complete 
0689084f485b: Pull complete 
Digest: sha256:38e7c463209e3c5b7f1fcb79bb250e4653a66f3be9f23f5d175eeeadf8c3da79
Status: Downloaded newer image for registry.access.redhat.com/ubi8/ubi:latest
[root@634052a6ad62 /]# more /etc/redhat-release 
Red Hat Enterprise Linux release 8.6 (Ootpa)
[root@634052a6ad62 /]# ls /
bin  boot  dev    etc  home  lib    lib64  lost+found  media  mnt  opt  proc  root    run  sbin  srv    sys  tmp  usr  var

Sample custom image


[dave@dave simple]$ more Dockerfile 
FROM registry.access.redhat.com/ubi8/ubi

RUN dnf install -y python3

CMD mkdir /myapp

WORKDIR /myapp

COPY ./myapp.sh .

CMD ./myapp.sh

Build image

$ docker build -t redhat-ubi-myapp .
Sending build context to Docker daemon  4.096kB
Step 1/6 : FROM registry.access.redhat.com/ubi8/ubi
 ---> 16fb1f57c5af
Step 2/6 : RUN dnf install -y python3
 ---> Using cache
 ---> 22a66860e864
Step 3/6 : CMD mkdir /myapp
 ---> Using cache
 ---> 1c724139c1c9
Step 4/6 : WORKDIR /myapp
 ---> Using cache
 ---> 3ca288265be2
Step 5/6 : COPY ./myapp.sh .
 ---> 22db0568addf
Step 6/6 : CMD ./myapp.sh
 ---> Running in 5328a64d06ad
Removing intermediate container 5328a64d06ad
 ---> af70183187f5
Successfully built af70183187f5
Successfully tagged redhat-ubi-myapp:latest

Run image

[dave@dave simple]$ docker run redhat-ubi-myapp
Hello,world!
Red Hat Enterprise Linux release 8.7 (Ootpa)

Saturday, October 15, 2022

Remove deprecated Oracle JDBC classes oracle.sql.ArrayDescriptor, oracle.sql.STRUCT, oracle.sql.StructDescriptor

 HOWTO

 
 
package dave.service;

import java.sql.Array;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Struct;

import javax.annotation.sql.DataSourceDefinition;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import dave.entity.Account;
import oracle.jdbc.OracleConnection;
import oracle.sql.ArrayDescriptor;
import oracle.sql.SQLName;
import oracle.sql.STRUCT;
import oracle.sql.StructDescriptor;

@Stateless
//Data Source defined for JPA. It assume the derby database is started up and listen to localhost:1527
@DataSourceDefinition(name = "java:module/env/mavenArchetypeDataSource", className = "org.apache.derby.jdbc.ClientXADataSource", portNumber = 1527, serverName = "localhost", databaseName = "examples", user = "examples", password = "examples", properties = {
        "create=true", "weblogic.TestTableName=SQL SELECT 1 FROM SYS.SYSTABLES" })
public class AccountManagerImpl implements AccountManager {

    @PersistenceContext
    private EntityManager em;

    public void depositOnAccount(String name, float amount) {
        Account account = em.find(Account.class, name);
        if (account == null) {
            account = new Account();
            account.setName(name);
        }
        account.setAmount(account.getAmount() + amount);
        em.persist(account);
    }

    public Account findAccount(String name) {

        em.getTransaction().begin();
        Connection connection = em.unwrap(java.sql.Connection.class);

        try {
            useDeprecatedOracleConnection(connection);
        } catch (SQLException e) {
            e.printStackTrace();
        }

        try {
            useOracleConnection(connection);
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return em.find(Account.class, name);
    }

    private void useDeprecatedOracleConnection(java.sql.Connection connection) throws SQLException {

        OracleConnection oracleConnection = null;

        if (connection.isWrapperFor(OracleConnection.class)) {
            oracleConnection = connection.unwrap(OracleConnection.class);
        } else {
            // recover, not an oracle connection
        }

        Object[] reportArray = new Object[3];
        STRUCT[] struct = new STRUCT[1];

        ArrayDescriptor arrayDescriptor = new ArrayDescriptor(
                new SQLName("T_REPORT_TABLE", (OracleConnection) connection), connection);
        StructDescriptor structDescriptor = StructDescriptor.createDescriptor("R_REPORT_OBJECT", connection);

        oracle.sql.ARRAY reportsArray = new oracle.sql.ARRAY(arrayDescriptor, connection, struct);

    }

    private void useOracleConnection(java.sql.Connection connection) throws SQLException {

        OracleConnection oracleConnection = null;

        if (connection.isWrapperFor(OracleConnection.class)) {
            oracleConnection = connection.unwrap(OracleConnection.class);
        } else {
            // recover, not an oracle connection
        }

        Object[] reportArray = new Object[3];
        Struct[] struct = new Struct[1];

        int arrayIndex = 0;

        struct[arrayIndex++] = connection.createStruct("R_REPORT_OBJECT", reportArray);

        Array reportsArray = ((OracleConnection) connection).createOracleArray("T_REPORT_TABLE", struct);

    }
}