millo74 opened a new issue, #9559:
URL: https://github.com/apache/netbeans/issues/9559
### Apache NetBeans version
Apache NetBeans 31
### What happened
Hi!
I find very useful the panel Services > Docker, where you can easily see and
manage Images and Containers.
before explaining the problem, a little premise.
Today's security best practices suggest to use a .env file to store
env-variables that is better not to include into a artifact (war/jar),
and that normally are managed by Kubernetes via Secrets: a classical example
are DB variables (DB_URL, DB_USER, DB_PWD)
And here is the problem.
if you just use terminal/console to build and run a Docker project, you can
tell Docker to use this .env file.
for example:
Dockerfile:
# BUILD #############################################
FROM eclipse-temurin:17-jre-alpine
WORKDIR /app
COPY target/MyProj-0.0.1.jar app.jar
COPY .env .env
# RUN #############################################
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]
command to build:
docker build --build-arg SKIP_TESTS=true -t myproject .
command to run (using .env variables) :
docker run -p 8080:8080 --env-file .env myproject
so my step on Netbeans simply are these 2:
1) from Dockerfile, right click, Build... , fill all required fields, and
everything is ok, creating new IMAGE under Docker images tree interface.
2) from this new image, right click, Run...
and that's the point: when Run start, the .env variables are ignored
I dont know in Run Dialog, how to add extra param "--env-file .env" ; I've
tried in Command input box, but nothing happen, or maybe I write something
wrong into this filed.
Can anybody help me to understand if I've made mistakes, or the .env feature
is missing in the current Docker Service?
thanks!
### Language / Project Type / NetBeans Component
Java Maven Web application project
### How to reproduce
with dockers running, simply create a java web project that simply print a
System.getenv("MSG"):
1) create a .env file with this content:
MSG=johnDoe123
2) create a Dockerfile in same root of pom.xml
# BUILD #############################################
FROM eclipse-temurin:17-jre-alpine
WORKDIR /app
COPY target/HelloDocker-0.0.1.jar app.jar
COPY .env .env
# RUN #############################################
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]
3) from Dockerfile, right click, BUILD.... and create the image
4) in Services > Docker > Local Docker > Images > HelloDocker, right click,
RUN ... and complete.
5) from Browser: http://localhost:8080/
and you can see that values is not the one stored in .env file
[HelloDocker.zip](https://github.com/user-attachments/files/30987045/HelloDocker.zip)
### Did this work correctly in an earlier version?
No / Don't know
### Operating System
windows 11
### JDK
26, but build with 17 version
### Apache NetBeans packaging
Apache NetBeans binary zip
### Anything else
it occurs always, because I think is a missing feature
### Are you willing to submit a pull request?
No
--
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]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists