I have a Spring boot application running using docker, it works perfectly for my development in local but I want to deploy my app on a dev server using the same docker.
The problem is that I have different application.yaml depending on the environment, like application-local.yaml and application-dev.yaml
This is my docker-compose.yml:
version: "3"
services:
backend:
network_mode: "host"
container_name: hebergement-backend
build:
context: .
restart: unless-stopped
volumes:
- /var/lib/hebergement/data:/var/lib/hebergement/data
And the dockerfile:
FROM maven:3.6.3-openjdk-11 AS MAVEN_BUILD
COPY pom.xml /build/
COPY api /build/api/
COPY commons /build/commons/
WORKDIR /build/
RUN mvn package
FROM openjdk:11-jdk-slim
COPY --from=MAVEN_BUILD /build/api/target/*.jar app.jar
COPY --from=MAVEN_BUILD /build/commons/target/*.jar commons.jar
ENTRYPOINT ["java","-jar","-Dspring.profiles.active=local","/app.jar"]
In the Dockerfile, I have my local profile set. Is there a way to change the active profile without editing the Dockerfile, like using a parameter or an env variable?