Hasan-J commented on PR #25251:
URL: https://github.com/apache/airflow/pull/25251#issuecomment-1200203640

   Hello
   
   After trying to create a symlink I discovered it's not as straightforward as 
I thought it would be.
   
   The problem is the image already has the directory `/opt/airflow` and that 
prevents me from creating the symlink as you can't overwrite a directory, so 
you have to remove it first. Removing that dir first also doesn't solve the 
problem because of how the initialization scripts (e.g. 
`_in_container_script_init`) work. `/opt/airflow` would be removed by the 
`BREEZE_INIT_COMMAND` in `run_init_script.sh` before 
`in_container_fix_ownership` function runs for instance and that would break 
things. 
   
   Another solution would be to also mount the repo to `/opt/airflow` in 
addition to the original mount which is `/workspaces/airflow`. I looked at the 
[initializeCommand](https://code.visualstudio.com/docs/remote/devcontainerjson-reference#_lifecycle-scripts)
 in order to detect the volume name codespaces creates when launching the 
container:
   
   `.devcontainer/devcontainer.json`
   ```yaml
   ...,
       "initializeCommand": 
"/workspaces/airflow/scripts/devcontainer_initialize_command.sh"
   }
   ```
   `devcontainer_initialize_command.sh` would detect the volume name and writes 
it to `.env` file relative to `scripts/ci/docker-compose/devcontainer.yml`
   
   Then use env variable substitution in:
   
   `scripts/ci/docker-compose/devcontainer.yml`
   ```yaml
   ...,
   volumes:
    ...
    - workspace:/opt
   
   volumes:
     workspace:
       external: true
       name: ${DEVCONTAINER_VOLUME}
   ``` 
   
   The only unwanted side-effect of this solution is the new mount entry `- 
workspace:/opt` it will overwrite the whole `/opt` dir removing the microsoft 
odbc tool already installed in the image.
   
   ---
   
   Plus, one more annoying thing (but still a bit acceptable I think) is that 
codespaces' default folder and terminal workdir would still be 
`/workspaces/airflow`. We can change the terminal default dir:
   
   `.devcontainer/devcontainer.json`
   ```yaml
   ...,
   "settings": {
     "terminal.integrated.cwd": "/opt/airflow"
   },
   ...
   ```
   
   But that's about it. People should be careful when copying full paths (not 
relative) from the side explorer window.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to