devspace-sh / devspace

DevSpace - The Fastest Developer Tool for Kubernetes ⚡ Automate your deployment workflow with DevSpace and develop software directly inside Kubernetes.
https://devspace.sh
Apache License 2.0
4.3k stars 361 forks source link

Symlinks need special care and have to be excluded using uploadExcludePaths so that the files are downloaded again in container #2047

Closed tukobadnyanoba closed 2 years ago

tukobadnyanoba commented 2 years ago

What happened?

In V6, uploadExcludePaths is missing from devspace.yaml and it leads to sync node_modules from local to container. The devspace-quickstart-nodejs project fails to start as it uses the synched version of node_modules (/node_modules/.bin/nodemon is not symlink anymore and nodemon will not get the reference of ../lib)

sync:
  - path: ./
    uploadExcludePaths:
      - Dockerfile
      - node_modules/

This issue will occur wherever symlinks are involved. We either need to add uploadExcludePaths back to devspace.yaml or update the docs to let the user know about this.

What did you expect to happen instead?

devspace-quickstart-nodejs should work without any changes.

How can we reproduce the bug? (as minimally and precisely as possible) Use devspace v6.0.0-alpha.14 to generate devspace.yaml,

My devspace.yaml:

version: v2beta1
name: devspace-quickstart-nodejsgit

# This is a list of `pipelines` that DevSpace can execute (you can define your own)
pipelines:
  # This is the pipeline for the main command: `devspace dev` (or `devspace run-pipeline dev`)
  dev:
    run: |-
      run_dependency_pipelines --all    # 1. Deploy any projects this project needs (see "dependencies")
      create_deployments --all          # 2. Deploy Helm charts and manifests specfied as "deployments"
      start_dev app                     # 3. Start dev mode "app" (see "dev" section)
  # You can run this pipeline via `devspace deploy` (or `devspace run-pipeline deploy`)
  deploy:
    run: |-
      run_dependency_pipelines --all                    # 1. Deploy any projects this project needs (see "dependencies")
      build_images --all -t $(git describe --always)    # 2. Build, tag (git commit hash) and push all images (see "images")
      create_deployments --all                          # 3. Deploy Helm charts and manifests specfied as "deployments"

# This is a list of `images` that DevSpace can build for this project
# We recommend to skip image building during development (devspace dev) as much as possible
images:
  app:
    image: mahendrabagul/app
    dockerfile: ./Dockerfile

# This is a list of `deployments` that DevSpace can create for this project
deployments:
  app:
    # This deployment uses `helm` but you can also define `kubectl` deployments or kustomizations
    helm:
      # We are deploying this project with the Helm chart you provided
      chart:
        name: component-chart
        repo: https://charts.devspace.sh
      # Under `values` we can define the values for this Helm chart used during `helm install/upgrade`
      # You may also use `valuesFiles` to load values from files, e.g. valuesFiles: ["values.yaml"]
      values:
        containers:
          - image: mahendrabagul/app
        service:
          ports:
            - port: 3000

# This is a list of `dev` containers that are based on the containers created by your deployments
dev:
  app:
    # Search for the container that runs this image
    imageSelector: mahendrabagul/app
    # Replace the container image with this dev-optimized image (allows to skip image building during development)
    devImage: ghcr.io/loft-sh/devspace-containers/javascript:17-alpine
    # Forward the following ports to be able access your application via localhost
    ports:
      - port: "9229"
      - port: "3000"
    # Open the following URLs once they return an HTTP status code other than 502 or 503
    open:
      - url: http://localhost:3000
    # Open a terminal and use the following command to start it
    terminal:
      command: ./devspace_start.sh
    # Sync files between the local filesystem and the development container
    sync:
      - path: ./
    # Inject a lightweight SSH server into the container (so your IDE can connect to the remote dev env)
    ssh:
      enabled: true
    # Make the following commands from my local machine available inside the dev container
    proxyCommands:
      - command: devspace
      - command: kubectl
      - command: helm
      - command: git

# Use the `commands` section to define repeatable dev workflows for this project 
commands:
  migrate-db:
    command: |-
      echo 'This is a cross-platform, shared command that can be used to codify any kind of dev task.'
      echo 'Anyone using this project can invoke it via "devspace run migrate-db"'

# Define dependencies to other projects with a devspace.yaml
# dependencies:
#   api:
#     git: https://...  # Git-based dependencies
#     tag: v1.0.0
#   ui:
#     path: ./ui        # Path-based dependencies (for monorepos)

Local Environment:

Anything else we need to know?

/kind bug

FabianKramm commented 2 years ago

@tukobadnyanoba thanks a lot for the issue! Yes you are totally correct, we need to exclude those for our quickstart projects