When running skaffold dev
with a container that has a listener (in this case Express), the container hangs as expected.
If I remove the listener with simple executable code, it keeps running it over and over.
I tried to search in the documentation but all I can see is that Skaffold should re-run the code only if you make changes.
I expected Skaffold would terminate the container after the run.
Are the restarts a normal behavior? Should I only add to Skaffold services that have listeners?
The following code results in seeing the “test” console.log every few seconds.
skaffold.yaml
apiVersion: skaffold/v2alpha3
kind: Config
deploy:
kubectl:
manifests:
- ./dpl/*
build:
local:
push: false
artifacts:
- image: myuser/myworker
context: myworker
docker:
dockerfile: Dockerfile
sync:
manual:
- src: 'src/**/*.ts'
dest: .
index.ts
//import express from 'express'
//const app = express()
console.log('test')
//app.listen(3000, () => {
// console.log('Listening on port 3000!')
//})
package.json
{
"name": "myworker",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "ts-node-dev --poll src/index.ts"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@types/express": "^4.17.21",
"express": "^4.19.2",
"ts-node-dev": "^2.0.0",
"typescript": "^5.4.5"
}
}
Dockerfile
FROM node:alpine
WORKDIR /app
COPY package.json .
RUN npm install --omit=dev
COPY . .
CMD ["npm", "start"]