Comments (5)
Thanks for the suggestion.
I can't think of a reason why we wouldn't want publishing an updated latest tag to be the default behavior.
I don't think that all users would agree with this. If images are being built and published from a CI pipeline, you may not want latest
to be updated with every build, but instead you might want to explicitly decide when to promote a build to latest
. Changing the default behavior like this could be quite a surprise for many users.
If we want to make it optional, we could even provide a new flag such as
image.publishLatest
With the current functionality, if you wanted to always publish a latest
along with the versioned tag, you would do something like this:
<project>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<name>example.com/library/${project.artifactId}:${project.version}</name>
<tags>
<tag>example.com/library/${project.artifactId}:latest</tag>
<tags>
<publish>true</publish>
</image>
</configuration>
</plugin>
</plugins>
</build>
</project>
A new option like image.publishLatest
would eliminate the need for the <tags></tags>
section, but in a much less flexible way. I don't think implementing a new, less flexible, option to replace something that can already be done has value. I also would not want to combine the behavior of the <publish>true</publish>
option and a tagging option into one new option.
Are you doing something different from this <tags></tags>
example now, or do you find this configuration too verbose?
from spring-boot.
@scottfrederick - I guess my question would be, what is the recommended approach to do this via the command line in CI when we need to set a custom tag name and also publish an updated latest
tag while also having to pass credentials to authenticate to the docker registry?
from spring-boot.
We typically don't expose the more complex and/or nested option types as command-line parameters for Maven plugin goals (including env
, buildpacks
, bindings
, and tags
for spring-boot:build-image
). I think we added support for docker.publishRegistry.username
and docker.publishRegistry.password
as command-line options because it is likely that these contain sensitive information that you would not want to hard-code in pom.xml
.
If you need to set tags or other options conditionally, the recommended approach is to use Maven profiles and activate the appropriate profile from the command line using mvn -P <profileName>
.
from spring-boot.
@scottfrederick - Thanks for the feedback. I'd say that since Spring Boot is built for the enterprise and large-scale business use-cases that typically have private docker registries, I'd recommend adding the image.tags
option as a command-line parameter so that it can be set via CI at build/publish time. Also, it would be great to be able to set the docker.publishRegistry.*
parameters without having to manually pipe them into the pom.xml
as mentioned here since we have to regularly pull these secrets from an external secrets store or GitHub Actions.
I was able to workaround these constraints by doing the following. Hopefully this helps someone if they're encountering the same issue.
pom.xml
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<docker>
<publishRegistry>
<username>${docker.publishRegistry.username}</username>
<password>${docker.publishRegistry.password}</password>
</publishRegistry>
</docker>
<image>
<tags>
<tag>docker.artifactory.xyz.com/my_image:latest</tag>
</tags>
</image>
</configuration>
</plugin>
CLI Command
mvn spring-boot:build-image \
-Dmaven.test.skip=true \
-Ddocker.publishRegistry.username=username \
-Ddocker.publishRegistry.password=password \
-Dspring-boot.build-image.publish=true \
-Dspring-boot.build-image.imageName=docker.artifactory.xyz.com/my_image:generated_image_tag
from spring-boot.
@dja557 The technique that you've shown here is very similar to what we recommend in our documentation for overriding Maven configuration properties on the command line. In the case of credentials like these, I think it is more likely that the values will be environment variables populated by a CI system from a secrets store rather than command-line parameters.
We appreciate the feedback and suggestions, but I don't think we want to do anything more here.
from spring-boot.
Related Issues (20)
- Spring boot 2.7.6 throwing NoHandler Exception for GET '/test/v1' HOT 1
- Change spring-boot-buildpack-platform api dependencies to implementation
- Document how an SslBundle name is derived from environment variables HOT 2
- Testcontainers @DynamicPropertySource and @Container execution order doesn't work properly HOT 2
- Unable to configure opentelemetry to service HOT 3
- SBOM actuator endpoint doesn't work in a native image HOT 3
- JdbcSQLSyntaxErrorException after upgrade to 3.3.0 HOT 7
- Warn in the documentation that spring.profiles.group can only be used in non-profile-specific documents
- Fix various minor inconsistencies of the documentation
- Add Kotlin example for @Testcontainers
- Add platform option for image building
- Application fails to start when server.tomcat.threads.max < 10 HOT 3
- CDS extract fails if application has its own META-INF directory HOT 3
- org.springframework.boot/spring-boot-starter-test Does not work with a module path HOT 1
- MessagingAnnotationBeanPostProcessor or ProxyTransactionManagementConfiguration BeanPostProcessor error HOT 6
- upgrade 3.2.6 corrupts published parent pom artifact HOT 8
- In 3.2.3+ , the auto-configured reactiveNeo4jTransactionManager may caused a failure due to multiple TransactionManager beans
- Gradle Plugin "Getting Started" documentation section out of date HOT 3
- Multiple values in X-Forwarded-Host not supported by NATIVE forward headers strategy HOT 1
- The value of the tomcat.threads.config.max metric is always -1, irrespective of the configured maximum number of threads HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-boot.