thiagoelg commented on PR #2225:
URL: 
https://github.com/apache/incubator-kie-tools/pull/2225#issuecomment-2038414900

   Hey @Josephblt, I gave this a better thought (and testing) and I don't think 
using Environment Variables for the port makes sense (I know... I was the one 
that wrote that in the original issue, my bad).
   
   It doesn't make sense because the `EXPOSE` instruction is not executed 
during runtime, so the exposed port will always be the one defined in the ARG.
   So let's say we set the ARG port as 8080 during build time, but we set the 
ENV as 9022 during runtime. The exposed port will still be 8080, but the app 
will be running at 9022.
   Now, according to the Docker documentation, the 
[EXPOSE](https://docs.docker.com/reference/dockerfile/#expose) instruction is 
only a way to document the port that is expected to be available, but in 
practice, you can still map any container port to any host port. The problem is 
that Kubernetes (and OpenShift) usually expects the exposed port to be the one 
where the app is available, so by default, all Services are created pointing to 
these ports.
   
   Having said all that, having the ARGs for defining the ports is enough, and 
we don't need to change them during runtime.
   
   What do you think?
   
   PS1.: When using ARGs we can revert those `sed` commands back to the 
Containerfile.
   
   PS2.: I discovered that OpenShift creates a bunch of environment variables 
by itself on its containers, potentially overwriting the ENVs we defined here, 
take a look:
   ```
   KUBERNETES_SERVICE_PORT_HTTPS=443
   RUNTIME_TOOLS_TASK_CONSOLE_WEBAPP_IMAGE_SERVICE_PORT_8080_TCP=8080
   WORKSPACEB8CB941D988C49CF_SERVICE_SERVICE_HOST=172.30.106.115
   KUBERNETES_SERVICE_PORT=443
   RUNTIME_TOOLS_TASK_CONSOLE_WEBAPP_IMAGE_PORT_8080_TCP_PROTO=tcp
   HOSTNAME=runtime-tools-task-console-webapp-image-6b5df5fcbc-bn2jw
   WORKSPACEB8CB941D988C49CF_SERVICE_PORT_4444_TCP=tcp://172.30.106.115:4444
   NSS_SDB_USE_CACHE=no
   WORKSPACEB8CB941D988C49CF_SERVICE_PORT_4444_TCP_PORT=4444
   PWD=/
   WORKSPACEB8CB941D988C49CF_SERVICE_SERVICE_PORT_EXEC=4444
   RUNTIME_TOOLS_TASK_CONSOLE_WEBAPP_IMAGE_SERVICE_PORT=8080
   container=oci
   HOME=/
   KUBERNETES_PORT_443_TCP=tcp://172.30.0.1:443
   WORKSPACEB8CB941D988C49CF_SERVICE_PORT=tcp://172.30.106.115:4444
   RUNTIME_TOOLS_TASK_CONSOLE_WEBAPP_IMAGE_PORT_8080_TCP_ADDR=172.30.151.27
   RUNTIME_TOOLS_TASK_CONSOLE_WEBAPP_IMAGE_PORT_BLA=8080
   TERM=xterm
   RUNTIME_TOOLS_TASK_CONSOLE_WEBAPP_IMAGE_SERVICE_HOST=172.30.151.27
   WORKSPACEB8CB941D988C49CF_SERVICE_SERVICE_PORT=4444
   SHLVL=1
   KUBERNETES_PORT_443_TCP_PROTO=tcp
   KUBERNETES_PORT_443_TCP_ADDR=172.30.0.1
   RUNTIME_TOOLS_TASK_CONSOLE_WEBAPP_IMAGE_PORT_8080_TCP_PORT=8080
   
RUNTIME_TOOLS_TASK_CONSOLE_WEBAPP_IMAGE_PORT_8080_TCP=tcp://172.30.151.27:8080
   KUBERNETES_SERVICE_HOST=172.30.0.1
   KUBERNETES_PORT=tcp://172.30.0.1:443
   KUBERNETES_PORT_443_TCP_PORT=443
   WORKSPACEB8CB941D988C49CF_SERVICE_PORT_4444_TCP_ADDR=172.30.106.115
   PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
   RUNTIME_TOOLS_TASK_CONSOLE_WEBAPP_IMAGE_PORT=tcp://172.30.151.27:8080
   WORKSPACEB8CB941D988C49CF_SERVICE_PORT_4444_TCP_PROTO=tcp
   _=/usr/bin/printenv
   ```
   Out of all of these, only `RUNTIME_TOOLS_TASK_CONSOLE_WEBAPP_IMAGE_PORT_BLA` 
was defined by me, as `RUNTIME_TOOLS_TASK_CONSOLE_WEBAPP_IMAGE_PORT` was being 
overwritten by OpenShift.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to