Why does skaffold build work but not skaffold run or skaffold dev?

Viewed 329

I have a local NPM/Yarn repository "verdaccio" running in a docker container, bound to my host machine at http://0.0.0.0:4873/.

I am trialling skaffold with minikube.

My Dockerfile config requires two build args:

ARG NPM_TOKEN
ARG PACKAGE_REPO_DOMAIN

Which are used in my .yarnrc.yml file:

yarnPath: .yarn/releases/yarn-3.2.0.cjs
nodeLinker: "node-modules"
npmRegistryServer: "http://${PACKAGE_REPO_DOMAIN}:4873/"
httpRetry: 10
httpTimeout: 100000
# networkConcurrency: 2
unsafeHttpWhitelist: 
  - "0.0.0.0"
  - localhost
  - verdaccio
  - host.minikube.internal
  - host.docker.internal
npmRegistries:
  "http://${PACKAGE_REPO_DOMAIN}:4873":
    npmAlwaysAuth: true
    npmAuthToken: ${NPM_TOKEN}

The configured domain is host.minikube.internal. Below is my skaffold yaml, notice I bound network to "host":

apiVersion: skaffold/v2beta28
kind: Config
build:
  local:
    push: false
  artifacts:
  - image: my-app
    docker:
      dockerfile: ./my-app/Dockerfile
      target: dev
      network: "host"
      buildArgs:
        NPM_TOKEN: "***REDACTED***"
        PACKAGE_REPO_DOMAIN: "host.minikube.internal"
    context: ../
    sync: 
      manual:
        - src: 'my-app/**/*.*'
          dest: ./my-app
        - src: './shared'
          dest: './shared'
        - src: '.yarn'
          dest: '.yarn'
deploy:
  helm:
    releases:
      - name: my-app
        chartPath: ../../infrastructure/helm/charts/my-app
        artifactOverrides:
          image: my-app
        imageStrategy:
          fqn: {}

When running skaffold build then it works and builds the image fine. However when running either skaffold dev or skaffold run then yarn install hangs when building. This means that yarn's failing to reach the verdaccio local npm repository. I don't understand why though - surely it's still being built within the minikube environment and should use host.minikube.internal -> localhost ?

NB: I have remembered to also run this before skaffold (still fails):

skaffold config set --global local-cluster true
eval $(minikube -p minikube docker-env)

Edit

I have since made a minimum reproduction here: https://github.com/gitn00b1337/skaffold-verdaccio

Requires yarn, minikube + helm.

CD into the project, then:

$ sudo chmod -R a+rw ./verdaccio/storage 
$ yarn install 
$ minikube start
$ docker-compose up (seperate terminal)
$ skaffold config set --kube-context minikube local-cluster true
$ eval $(minikube -p minikube docker-env)
$ skaffold build # works

$ skaffold run # fails
0 Answers
Related