Hello @Oliver Wilms I have test using the original Dockerfile:

# Stage 1
FROM node:8.17.0-alpine3.9 as node
LABEL maintainer "david.reche@intersystems.com"
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

# Stage 2
FROM nginx:1.13.12-alpine
COPY --from=node /usr/src/app/dist/ /usr/share/nginx/html/
COPY ./nginx.conf /etc/nginx/conf.d/default.conf

and the image for web app is build ok

docker images

REPOSITORY                                TAG              IMAGE ID       CREATED          SIZE

iris-explorer                             v1.1.0           066bda214946   19 minutes ago   20.8MB

  1. No, the postgresql is not in the docker-compose, but is easy to include:
version: '3.6'
services:
  db:
    image: postgres
    restart: always
    environment:
      POSTGRES_USER : demo
      POSTGRES_DB: demo
      POSTGRES_PASSWORD: demo
    container_name: demo-pg
    volumes:
      - ${PWD}/pg-scripts:/docker-entrypoint-initdb.d/
    ports:
      - 5432:5432

The Docker file is a bit messy because testing... sure you can clean it:

FROM openjdk:8 AS builder
ARG APP_HOME=/tmp/app

# copy JDBCTest
COPY src $APP_HOME/src

# copy JGW jars
COPY --from=intersystemsdc/jgw:latest /jgw/*.jar $APP_HOME/jgw/

# compile and create JDBCTest
WORKDIR $APP_HOME/src
RUN javac -classpath $APP_HOME/jar/*:$APP_HOME/jgw/* JDBCTest.java && \
    mkdir $APP_HOME/jar && \
    jar -cvf $APP_HOME/jar/JDBCTest.jar JDBCTest.class

WORKDIR $APP_HOME/jar/
ADD https://jdbc.postgresql.org/download/postgresql-42.2.18.jar .

FROM openjdk:8u252-jre

ENV GWDIR /jgw
ENV PORT 55555
# add LOG
ENV LOG /tmp/jgw-trace.log
ENV ISC_PACKAGE_INSTALLDIR /usr/irissys
ENV ISC_JARDIR $ISC_PACKAGE_INSTALLDIR/dev/java/lib/JDK18

COPY --from=store/intersystems/iris-community:2020.2.0.211.0 \
     $ISC_JARDIR/intersystems-gateway-3.1.0.jar \
     $ISC_JARDIR/intersystems-jdbc-3.1.0.jar \
     $ISC_JARDIR/intersystems-utils-3.1.0.jar \
     $ISC_PACKAGE_INSTALLDIR/dev/java/lib/gson/gson-2.8.5.jar \
     $GWDIR/

CMD java $JVMARGS -Xrs -classpath "$GWDIR/*" com.intersystems.gateway.JavaGateway $PORT $LOG 2>&1

COPY --from=builder /tmp/app/jar/*.jar $GWDIR/

## install additional packages for debug
RUN apt-get update && apt-get install -y procps

JDBCTest is a simple JDBC java class for testing the connection

I have manually set chmod +777 to jars but still getting the same error

Although I found the bug in EnsLib.JavaGateway.Common, I still unable to connect to the database. this is a trace from JG log:

<< CONNECT

Received: (20:40:50:976) [Job number = -1] [ThreadID = 14]
  0000:  17  00  00  00  02  00  00  00  00  00  00  00  59  57      ............YW
  000E:  17  01  6F  72  67  2E  70  6F  73  74  67  72  65  73      ..org.postgres
  001C:  71  6C  2E  44  72  69  76  65  72                          ql.Driver


 >> LOAD_JAVA_CLASS_SYNCH: org.postgresql.Driver

Sent: (20:40:50:977) [Job number = -1] [ThreadID = 14]
  0000:  00  00  00  00  02  00  00  00  00  00  00  00  59  57      ............YW



 << LOAD_JAVA_CLASS_SYNCH

Received: (20:40:50:979) [Job number = -1] [ThreadID = 14]
  0000:  5C  00  00  00  02  00  00  00  00  00  00  00  59  4D      \...........YM
  000E:  03  04  0B  1E  01  64  72  69  76  65  72  3A  6F  72      .....driver:or
  001C:  67  2E  70  6F  73  74  67  72  65  73  71  6C  2E  44      g.postgresql.D
  002A:  72  69  76  65  72  31  01  6A  64  62  63  3A  70  6F      river1.jdbc:po
  0038:  73  74  67  72  65  73  71  6C  3A  2F  2F  68  6F  73      stgresql://hos
  0046:  74  2E  64  6F  63  6B  65  72  2E  69  6E  74  65  72      t.docker.inter
  0054:  6E  61  6C  3A  35  34  33  32  2F  6C  63  77  05  01      nal:5432/demo..
  0062:  6C  63  77  05  01  6C  63  77                              demo..demo


 >> MESSAGE: 

  msgId: 11

Sent: (20:40:51:018) [Job number = -1] [ThreadID = 14]
  0000:  02  00  00  00  00  00  00  00  00  00  00  00  59  4D      ............YM
  000E:  02  05                                                      ..


 << MESSAGE

Received: (20:40:51:020) [Job number = -1] [ThreadID = 14]
  0000:  03  00  00  00  02  00  00  00  00  00  00  00  59  4D      ............YM
  000E:  03  04  01                                                  ...


 >> MESSAGE: 

  msgId: 1

Sent: (20:40:51:020) [Job number = -1] [ThreadID = 14]
  0000:  50  00  00  00  00  00  00  00  00  00  00  00  59  4D      P...........YM
  000E:  50  01  52  65  6D  6F  74  65  20  4A  44  42  43  20      P.Remote JDBC 
  001C:  65  72  72  6F  72  3A  20  4E  6F  20  73  75  69  74      error: No suit
  002A:  61  62  6C  65  20  64  72  69  76  65  72  20  66  6F      able driver fo
  0038:  75  6E  64  20  66  6F  72  20  64  72  69  76  65  72      und for driver
  0046:  3A  6F  72  67  2E  70  6F  73  74  67  72  65  73  71      :org.postgresq
  0054:  6C  2E  44  72  69  76  65  72  2E  20                      l.Driver. 


 << MESSAGE

Received: (20:40:51:023) [Job number = -1] [ThreadID = 14]
  0000:  00  00  00  00  00  00  00  00  00  00  00  00  59  34      ............Y4



 >> DISCONNECT

I am having "No suitable driver found for driver:org.postgresql.Driver". But the postgre JDBC jar file is in the /jgw directory... any help?

The directory show:

root@06fac93de710:/jgw# ls -l
total 1844
-rw-r--r-- 1 root  root     1796 Feb  7 17:19 JDBCTest.jar
-rwxr-xr-x 1 51773 52773  241622 Jun 26  2020 gson-2.8.5.jar
-rwxr-xr-x 1 51773 52773  116930 Jun 26  2020 intersystems-gateway-3.1.0.jar
-rwxr-xr-x 1 51773 52773  426856 Jun 26  2020 intersystems-jdbc-3.1.0.jar
-rwxr-xr-x 1 51773 52773   85272 Jun 26  2020 intersystems-utils-3.1.0.jar
-rw------- 1 root  root  1004719 Oct 15 13:11 postgresql-42.2.18.jar

And the JG is started with:

root@06fac93de710:/jgw# ps -ef
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 20:37 ?        00:00:00 /bin/sh -c java $JVMARGS -Xrs -classpath "$GWDIR/*" com.intersystems.gateway.JavaGateway $PORT $LOG 2>&1
root         8     1  0 20:37 ?        00:00:06 java -Xrs -classpath /jgw/* com.intersystems.gateway.JavaGateway 55555 /tmp/jgw-trace.log
root       161     0  0 20:59 pts/0    00:00:00 bash
root       193   161  0 21:02 pts/0    00:00:00 ps -ef
root@06fac93de710:/jgw# 

Tell me what is this in EnsLib.JavaGateway.Common??

Method initJG() As %Status
{
    Set ..%JavaGateway = ##class(%Net.Remote.Java.JavaGateway).%New()
    If ""'=..JGService {
        Set tItem=##class(Ens.Host).GetShadowInstance(..JGService,.tSC)  Quit:$$$ISERR(tSC) tSC
        //Set ..%JGServer=tItem.Server
        Set ..%JGPort=tItem.Port
        //Set ..%JGConnectTimeout=tItem.ConnectTimeout
        //Set ..%JGSSLConfig=tItem.SSLConfig
    } ElseIf ..#REQUIREJGSERVICE {
        Quit $$$ERROR($$$EnsErrGeneral,"In order to work this Adapter requires the JGService setting to be configured")
    }
    Quit $$$OK
}

This line is commented:

//Set ..%JGServer=tItem.Server

I test that if you replace or insert a new line instead of that with:

Set ..%JGServer=tItem.Address

And Set ENSLIB Database to Read/Write and compile the BO can connect!!!

Hello,

I am trying to use a simple Production with an Operation using EnsLib.SQL.OutboundAdapter. As I am running inside a Dcoker container I am trying to use your approach of running the JavaGateway in another container (https://github.com/intersystems-community/JavaGatewayImage).

So I configure the docker-compose in order to up two containers.

version: '3.6'
services:
  jgw:
    build:
      context: jgw
      dockerfile: Dockerfile
    restart: always
    ports: 
      - 2021:55555
  iris:
    build: 
      context: .
      dockerfile: Dockerfile
    restart: always
    ports: 
      - 51773
      - 52773
      - 53773
    volumes:
      - ~/iris.key:/usr/irissys/mgr/iris.key
      - ./:/irisdev/app

as you can see I am getting the JGW from port 2021.

I configured the JGW in a production:

  <Item Name="JGW" Category="" ClassName="EnsLib.JavaGateway.Service" PoolSize="1" Enabled="true" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
    <Setting Target="Host" Name="Address">host.docker.internal</Setting>
    <Setting Target="Host" Name="Port">2021</Setting>
  </Item>

I am using Mac so I have to use "host.docker.internal" or explicit IP in order to reach the right host.

Finally I configured a BO using SQL.OutboundAdapter in order to connect to an external PostgreSQL database:

  <Item Name="DbOperation" Category="" ClassName="demo.DbOperation" PoolSize="1" Enabled="true" Foreground="false" Comment="" LogTraceEvents="true" Schedule="">
    <Setting Target="Adapter" Name="Credentials">Demo</Setting>
    <Setting Target="Adapter" Name="DSN">jdbc:postgresql://host.docker.internal:5432/demo</Setting>
    <Setting Target="Adapter" Name="JDBCDriver">org.postgresql.Driver</Setting>
    <Setting Target="Adapter" Name="JGService">JGW</Setting>
  </Item>

As I want to use the configures JGW then I set the JGW config name at JGService setting.

Well the BO is UNABLE to connect to the database... after spend hours of investigation and testing, I check that from the JG container I can connect to the database without problems, but the problem persist. With a Ensemble trace level I can see the next:

The JG service connects and communicate with the external container without problems. I see this trace:

JGW -- JG PING: Invoking ##class(%Net.Remote.Gateway).%Ping(host.docker.internal, 2021, 4)
JGW -- Returned OK from OnProcessInput(); Output=, %WaitForNextCallInterval=1, %QuitTask=0

The JGW perfectly goes to host.docker.internal... but

SQLOperation -- Connecting to JavaGateway: 127.0.0.1:2021+%Net.Remote.Java.JDBCGateway:
SQLOperation -- ERROR ErrOutConnectFailed: JDBC Connect failed for 'jdbc:postgresql://host.docker.internal:5432/demo' / 'Demo' with error ERROR #5023: Remote Gateway Error: Connection cannot be established

Please see the 127.0.0.1 ... Do you have experience this? Do you have any workaround?

It seems like the EnsLib.SQL.OutboundAdaptor don't get the Server setting from JG and always use 127.0.0.1... that's crazy

Any help???

Hello @Mohamed Hassan Anver,

I think that the tutorial is for EF 6 that is designed for .NET Framework. And MS is not promoting more EF Framework, right now, MS has EF core as goal (check this: https://docs.microsoft.com/es-es/ef/efcore-and-ef6/ ) and is the right EF to go in my opinion.

However IRIS is not supporting EF Core https://community.intersystems.com/post/how-can-i-use-iris-net-core-entity-framework. :-( 

Any thought @Bob Kuszewski ?
 

I see.

So I guess I should use EnsLib.HL7.SchemaDocument class https://docs.intersystems.com/irisforhealthlatest/csp/documatic/%25CSP.Documatic.cls?APP=1&LIBRARY=ENSLIB&CLASSNAME=EnsLib.HL7.SchemaDocument but can't find an example of how import/export programatically.

In response to @Evgeny Shvarov I am talking about Custom HL7 Schemas (https://docs.intersystems.com/irisforhealthlatest/csp/docbook/Doc.View.cls?KEY=EHL72_tools#EHL72_customhl7schema_editor) in IRIS for Health. Use custom schemas is something very usual and I think that to include this import feature in Installer could be very useful... I'll try to make it works and if I am success I'll post the how-to :-D