Skaffold dev doesn't do automatic file sync for spring boot app

Viewed 165

I have a spring boot app that generates a jar artifact.I want to configure skaffold to make use of automatic file sync. Below are my config files : pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.13</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>rest-service-complete</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>rest-service-complete</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${project.parent.version}</version>
            </plugin>
        </plugins>
    </build>

</project>

Dockerfile

VOLUME /tmp
ARG DEPENDENCY=target/dependency
COPY ${DEPENDENCY}/BOOT-INF/lib /app/lib
COPY ${DEPENDENCY}/META-INF /app/META-INF
COPY ${DEPENDENCY}/BOOT-INF/classes /app
ENTRYPOINT ["java","-cp","app:app/lib/*","com.example.restservice.RestServiceApplication"]

deployment.yaml

kind: Deployment
metadata:
  labels:
    app: demo
  name: demo
spec:
  replicas: 1
  selector:
    matchLabels:
      app: demo
  strategy: {}
  template:
    metadata:
      labels:
        app: demo
    spec:
      containers:
      - image: mariatamas89/spring-boot-hw
        name: spring-boot-hw
        imagePullPolicy: Always
        resources: {}
      imagePullSecrets:
        - name: myregistrykey
status: {}
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: demo
  name: demo
spec:
  ports:
  - name: 8080-8080
    port: 8080
    protocol: TCP
    targetPort: 8080
  selector:
    app: demo
  type: LoadBalancer
status:
  loadBalancer: {}

skaffold.yaml

kind: Config
metadata:
  name: complete
build:
  tagPolicy:
    sha256: { }
  local:
    push: true
  artifacts:
  - image: mariatamas89/spring-boot-hw
    sync:
      infer:
        - '/target/dependency/app/com/example/*.java'
    docker:
      dockerfile: Dockerfile
      noCache: true
deploy:
  kubectl:
    manifests:
    - deployment.yaml

I run skaffold dev , app starts correctly , but when I do a change to a java file , nothing happens in the skaffold cli, the change is not picked up. Any ideas how to make skaffold file sync work?Thank you.

0 Answers
Related