i'm new to skaffold and have setup the yaml file as below which should sync any changes in the src folder in my project to goolge cloud build. Please note Im not using git.
When I run skaffold dev any changes in the src folder on the local machine (macos) are synced to google cloud build i.e the image is updated and deployed.
If I make any changes within src folder while skaffold dev is running, I notice skaffold identifies the changes but are not deployed to google cloud build.
How can i update the below yaml file which will also deploy the changes to google cloud build everytime i make a change any file within src folder. Currently I have to stop skaffold and rerun it for the changes to be deployed in google cloud build.
{
"name": "auth",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "ts-node-dev src/index.ts"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@types/express": "^4.17.12",
"express": "^4.17.1",
"express-validator": "^6.12.0",
"ts-node-dev": "^1.1.6",
"typescript": "^4.3.4"
}
}
apiVersion: skaffold/v2alpha3
kind: Config
deploy:
kubectl:
manifests:
- ./infra/k8s/*
build:
# local:
# push: false
googleCloudBuild:
projectId: ticketing-dev
artifacts:
- image: gcr.io/ticketing-dev/auth
context: auth
docker:
dockerfile: Dockerfile
sync:
manual:
- src: 'src/**/*.ts'
dest: .
FROM node:alpine
#create working dir within image called app
WORKDIR /app
COPY package.json .
RUN npm install
COPY . .
CMD ["npm", "start"]
apiVersion: apps/v1
kind: Deployment
metadata:
name: auth-depl
spec:
replicas: 1
selector:
matchLabels:
app: auth
template:
metadata:
labels:
app: auth
spec:
containers:
- name: auth
image: gcr.io/ticketing-dev/auth
---
apiVersion: v1
kind: Service
metadata:
name: auth-srv
spec:
selector:
app: auth
ports:
- name: auth
protocol: TCP
port: 3000
targetPort: 3000
Skaffold syncs changes to the running containers, not GCB. One of the requirements is that the container must contain tar
.
You haven't included your Dockerfile
, but one key point is that syncing files may not be sufficient: your app needs to detect and reload the changes. Most typescript apps use tsc-watch
to recompile and relaunch.
For example, I see something like the following using the Skaffold TypeScript example:
[node] 2:22:47 PM - Found 0 errors. Watching for file changes.
[node] Example app listening on port 3000.
Syncing 1 files for node-typescript-example:21b757dbdb147a87b0ce4b1e538ab93cdbc114e99515fdf4e398ed62a2b3809d
Watching for changes...
[node] 2:22:52 PM - File change detected. Starting incremental compilation...
[node]
[node]
[node] 2:22:52 PM - Found 0 errors. Watching for file changes.
[node] Example app listening on port 3000!
The [node]
lines are from within the container.