Skip to content

Fix the bug that app built by default Dockerfile cannot fetch Envs#107

Merged
haoozhang merged 1 commit into
azure-javaee:feature/sjadfrom
haoozhang:haozhan/dockerfile-fix
Jan 20, 2025
Merged

Fix the bug that app built by default Dockerfile cannot fetch Envs#107
haoozhang merged 1 commit into
azure-javaee:feature/sjadfrom
haoozhang:haozhan/dockerfile-fix

Conversation

@haoozhang

@haoozhang haoozhang commented Jan 17, 2025

Copy link
Copy Markdown

Fix the bug that app built by default Dockerfile cannot fetch Envs.

The root cause is that, use sh -c before, which make the command run in the shell context, and the Envs cannot work as expected. Now run the command directly and let Docker handle the command execution directly, ensuring the environment variables propagate correctly.

Test by running the https://github.com/azure-javaee/azure-spring-boot-samples/tree/main/postgresql/spring-cloud-azure-starter-jdbc-postgresql/spring-cloud-azure-postgresql-sample

// todo: hardcode jdk-21 as base image here, may need more accurate java version detection.
//const DefaultDockerfileForJavaProject = `FROM openjdk:21-jdk-slim
//COPY ./target/*.jar /app.jar
//ENTRYPOINT ["sh", "-c", "java -jar /app.jar"]`

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here use sh -c before, which make the command run in the shell context, and the Envs cannot work as expected.
Now run the command directly and let Docker handle the command execution directly, ensuring the environment variables propagate correctly.

@haoozhang

Copy link
Copy Markdown
Author

The test failures should not be because of this code change, will merge this first.

@haoozhang haoozhang merged commit b31578f into azure-javaee:feature/sjad Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants