I am working on a java (maven) project where the code on dev/testing environments is different than the production one. The different parts are mainly configuration files or files related to Docker, but still, this creates a lot of confusion. If I were to keep the pom file or the Dockerfile of prod, dev wouldn’t work and vice versa.
Right now, when deploying to prod,
I create a new branch in git from an existing deploy
branch that has already the different Dockerfile and pom.
There, I checkout the changes from the src/ directory like
$ git checkout origin/feature-name —- src/
and manually provide any other changes if necessary to the rest of the files.
All this process turns to be tedious with many possible errors around the corner (if let’s say I forget to change a version of a dependency). Furthermore, this stops me from automating the deployments to production. How can I work around this situation?
UPDATE
The actual code in the src/ directory is not changing. The changes between environments are
- dev/test environments are using secrets, but prod doesn't, meaning different docker-compose files and different entrypoint
- The pom file in production has additional elements (i.e. a parent pointing to a private artifact). As mentioned by @Saeed, using profiles cannot add/change or elements.
- The Dockerfile in production is using private images not accessible during development (or testing) I am using a public equivalent instead.