#### Running build stage in a multi-stage Dockerfile in Skaffold

I’m currently using Skaffold for local Kubernetes development and I’m in the process of converting my Dockerfile to a multi-stage format (based on this advice I came across) with dedicated stages for: base, dependencies, development, unit testing, and production. Actually I’m using this as a template.

Ultimately what I want is for the unit tests to be run automatically when the code is updated, thus removing the need to manually do npm test, python manage.py test, etc. and have a terminal open dedicated to that running. Also to avoid having a copy of the env vars locally (not quite there yet).

At any rate, this is what I have more skaffold.yaml and I’m not finding the Custom Test documentation particularly helpful.

apiVersion: skaffold/v2beta19
kind: Config
build:
artifacts:
- image: api
context: api
sync:
manual:
- src: "**/*.py"
dest: .
docker:
dockerfile: Dockerfile
target: development
- image: postgres
context: postgres
sync:
manual:
- src: "**/*.sql"
dest: .
docker:
dockerfile: Dockerfile.dev
local:
push: false
test:
- image: api-test
custom:
- command: docker build -f Dockerfile . -t api-test --target=test &&
docker run -it api-test --target=test
deploy:
kubectl:
manifests:
- k8s/dev/ingress.yaml
- k8s/dev/postgres.yaml
- k8s/dev/api.yaml
defaultNamespace: dev



I don’t get any output related to my tests results. The Pods spin up successfully, but nothing related to the unit tests.

I’m way of the mark I imagine with my - command:.

Suggestions for how to get this working or a better approach to automatically running this stage in my local development pipeline?

Source: Docker Questions