0

I implemented, in a spring boot application, the locale function.

On my local computer, with the dev and prod profile, when I add? Lang = en or? Lang = fr my view is automatically translated.

I just noticed that when I dockerize, with the prod profile, my project, on my production server, the? lang = en function no longer works.

I do not understand why.

Here is my DockerFile

FROM openjdk:11.0.11-oraclelinux7
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-Dspring.profiles.active=prod","-jar","/app.jar"]

To remove the version problem, I deleted the Dockerfile and I built my image with

./mvnw clean spring-boot: build-image

but the problem is the same. If from my server, I curl localhost:port?Lang=en I have no reaction.

Conclusion on my personal computer,? Lang = fr works with the prod and dev profile, but it does not work on the production server, which is contained in a docker ....

thank you so much


Ok!:

According to the following link After docker-compose build language switching does not work the problem comes from the lack of locale in the dockerfile. I have to test if by directly adding the locales to my server, if I can keep the openjdk image. To solve my problem I used the ubuntu image and I added the locales

Camel4488
  • 323
  • 1
  • 3
  • 9
  • What does the docker logs say? – aksappy Jul 19 '21 at 16:36
  • The docker log is the log of my spring-boot app. He didn't tell me anything abnormal! – Camel4488 Jul 19 '21 at 16:44
  • If I have something bizzard, I put a filter that logs the transaction. If I go to example.com/ instead of logging in "starting transaction /" it writes "starting transaction ac4fba7af416" from chodes instead of /. And it is valid for all the links – Camel4488 Jul 19 '21 at 16:47
  • Can you post the logs? It must be printing out the active profile in the logs in INFO – aksappy Jul 19 '21 at 16:47
  • I still don't understand, yet it uses the correct port for the prod profile as well as the correct postgres url ... So it reads the properties well ... it displays the messages in English but does not respond to? Lang = while that my local pc it works ... – Camel4488 Jul 19 '21 at 19:17
  • okay, and the URL is the same? And are you hitting the application inside docker directly, i.e no gateways/load balancers? – aksappy Jul 19 '21 at 19:45
  • I found the answer. In my dockerfile I used the openjdk11 image. I changed this image to ubuntu and added the locales in dockerfile. The problem is solved. I just have to test to put the openjdk image back and add the local directly to my vps! thank you so much!!! https://stackoverflow.com/questions/57876536/after-docker-compose-build-language-switching-does-not-work – Camel4488 Jul 19 '21 at 19:56
  • That is interesting. If that link fixes the issue, we might want to link this question to that SO. – aksappy Jul 19 '21 at 20:40
  • Does this answer your question? [After docker-compose build language switching does not work](https://stackoverflow.com/questions/57876536/after-docker-compose-build-language-switching-does-not-work) – aksappy Jul 20 '21 at 13:42

0 Answers0