Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b544ac3

Browse files
author
Dave Syer
committed
Use custom build in skaffold
1 parent 4caf8f2 commit b544ac3

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

README.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,4 +429,50 @@ Port forwarding service/app in namespace default, remote port 80 -> address 127.
429429
...
430430
```
431431

432-
You can test that the app is running on port 4503. Because of the way we defined our `Dockerfile`, it is watching for changes in the jar file. So we can make as many changes as we want to the source code and they only get deployed if we rebuild the jar.
432+
You can test that the app is running on port 4503. Because of the way we defined our `Dockerfile`, it is watching for changes in the jar file. So we can make as many changes as we want to the source code and they only get deployed if we rebuild the jar.
433+
434+
## Using Spring Boot Docker Images with Skaffold
435+
436+
Skaffold has a custom builder option, so we can use that to hook in the buildpack support. First we need to make the image name a parameter of the build (in `pom.xml`):
437+
438+
```xml
439+
<properties>
440+
<java.version>1.8</java.version>
441+
<docker.image>localhost:5000/apps/${project.artifactId}</docker.image>
442+
</properties>
443+
<build>
444+
<plugins>
445+
<plugin>
446+
<groupId>org.springframework.boot</groupId>
447+
<artifactId>spring-boot-maven-plugin</artifactId>
448+
<configuration>
449+
<image>
450+
<name>${docker.image}</name>
451+
</image>
452+
</configuration>
453+
</plugin>
454+
</plugins>
455+
</build>
456+
```
457+
458+
and then we can set up Skaffold like this:
459+
460+
```yaml
461+
apiVersion: skaffold/v2alpha4
462+
kind: Config
463+
metadata:
464+
name: demo-app--
465+
build:
466+
artifacts:
467+
- image: localhost:5000/apps/demo
468+
custom:
469+
buildCommand: ./mvnw spring-boot:build-image -D docker.image=$IMAGE && docker push $IMAGE
470+
dependencies:
471+
paths:
472+
- src
473+
- pom.xml
474+
deploy:
475+
kustomize:
476+
paths:
477+
- "src/main/k8s/demo/"
478+
```

0 commit comments

Comments
 (0)