Make node build in pipeline with external .env

giving up…
I’m trying to make npm build (react scripts) and in meantime inject custom .env file (build/env related) into pipeline work directory.

Trying hard with host volumes but seems like it does not mounting files.

first, my runner after mount directory from host machine:

[drone@ci1 ~]$ docker exec runner ls -la /env/bs-frontend
total 4
drwxrwxrwx    2 1002     1002            21 Feb 10 19:22 .
drwxrwxrwx    3 1002     1002            25 Feb 10 18:56 ..
-rwxrwxrwx    1 1002     1002           430 Feb 10 19:01 env-dev

(as you can see i even tried to chmod everything to fully open…)

part of my pipeline:

---
kind: pipeline
type: docker
name: dev
trigger:
    branch: master
    event: push
concurrency:
    limit: 1
volumes:
  - name: dotenv
    host:
      path: /env/bs-frontend

steps:

- name: build
  image: node
  volumes:
    - name: dotenv
      path: /env
  commands:
    - ls -al /env
    - ls -al /env/dev
    - exit 1

result of pipeline:

+ ls -al /env
total 0
drwxr-xr-x. 3 root root 17 Feb 10 19:06 .
drwxr-xr-x. 1 root root 64 Feb 10 19:23 ..
drwxr-xr-x. 2 root root  6 Feb 10 19:06 dev
+ ls -al /env/dev
total 0
drwxr-xr-x. 2 root root  6 Feb 10 19:06 .
drwxr-xr-x. 3 root root 17 Feb 10 19:06 ..
+ exit 1

repository is marked as trusted, its self hosted drone… Anyone any thoughts ?

Maybe there is another tested workflow for that which is not findable in internet ? :wink:

I created an env file at /tmp/env/.env and then mounted the /tmp/env directory using the following configuration file:

kind: pipeline
type: docker
name: default

volumes:
- name: dotenv
  host:
    path: /tmp/env

steps:
- name: test
  image: alpine
  volumes:
  - name: dotenv
    path: /env
  commands:
  - ls -la /env

When I execute the above pipeline, I see the directory is correctly mounted and the .env file listed in the directory as expected:

% drone exec --trusted
[test:0] + ls -la /env
[test:1] total 4
[test:2] drwxr-xr-x    3 root     root            96 Feb 10 20:11 .
[test:3] drwxr-xr-x    1 root     root          4096 Feb 10 20:13 ..
[test:4] -rw-r--r--    1 root     root             0 Feb 10 20:11 .env

Is there a way to make this available to other pipelines in the same drone file?