Skip to content

Add command line option for OCI image name #20520

@dsyer

Description

@dsyer

When deploying to Kubernetes (for example) at dev time, it is useful to be able to modify the image name on the command line, so that it can always be unique and Kubernetes can detect the change and do a rolling update (or whatever it needs to do).

E.g. when using Skaffold, it presents a custom builder with an env var (IMAGE), so that you can do this automatically. This seems to be working for me:

apiVersion: skaffold/v2alpha4
kind: Config
build:
  artifacts:
  - image: localhost:5000/apps/demo
    custom:
      buildCommand: ./mvnw spring-boot:build-image -D docker.image=$IMAGE && docker push $IMAGE
      dependencies:
        paths:
        - src
        - pom.xml
deploy:
  kustomize:
    paths: 
    - "src/main/k8s/demo/"

But at the cost of having to modify the pom.xml and add the docker.image property:

	<properties>
		<java.version>1.8</java.version>
		<docker.image>localhost:5000/apps/${project.artifactId}</docker.image>
	</properties>
	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<image>
						<name>${docker.image}</name>
					</image>
				</configuration>
			</plugin>
		</plugins>
	</build>

It would be useful to not have to make those pom.xml changes, e.g. if Spring Boot had its own property that works as a -D out of the box.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions