3

There is anyway to add custom folder using symbolic link into data folder in Devilbox ? When i put the symbolic link the Auto Virtual Host ignore the folder.

Thank You.

Pirex360
  • 328
  • 2
  • 14

2 Answers2

3

I used to had the same exact issue but I solved it.

TL;DR; Solution:

  • Create a new file in the root of devilbox project called docker-compose.override.yml

  • Copy and paste this into the file

# IMPORTANT: The version must match the version of docker-compose.yml
---
version: '2.3'

services:
  php:
    volumes:
      - $HOME:$HOME
  httpd:
    volumes:
      - $HOME:$HOME
  • Now you are able to create symlinks such as

data/www/proj-slug/htdocs -> ~/your-custom-path

Explanation

Following the reply of @Pirex360 is not enough to use symlinks. Indeed, when you create the symlink, the vhost page says "There is no htdocs folder".

The problem is that everything inside Devilbox is "Dockerized", therefore your Docker container is not able to access to files and folder that are not mounted inside the Docker container.

Searching a bit online I have found an issue on the project repository that talks about here. Many users thought about the possibility to modify the docker-compose.yml file in order to mount the folder they need.

Docker, however, already provides a way to override docker compose file. The correct way is to create a docker-compose.override.yml file.

The configuration pasted above permit to mount the host user home folder inside the docker. As a matter of fact, you can find your home folder mounted in Docker homes.

You can check out the effect entering in the Docker environment by means of shell file

$ cd devilbox
$ ./shell.sh # or .bat
$ ls /home
devilbox/ yourusername/

Then each symlink pointing to /home/yourusername/custompath is working as expected!

Laravel public folder

If you are only trying to create a symlink that map public folder to htdocs you can use the guide provided by Devilbox, Setup Laravel.

@marcogmonteiro talked about this in a comment. However this method works only if you are symlinking files or folder that are not outside of the Docker visible tree.

Important disclaimer

This way of mounting your home folder into Docker breaks the isolation between the container and your files and folder. So, the Docker container, CAN read/write/execute your files.

Gabriele Serra
  • 381
  • 3
  • 10
2

Ok, i make it work. For future reference, make all the root folders by hand, but inside of the root folders symbolic links are accepted.

data/www/proj-slug/{htdocs} width {htdocs} -> ~/git/proj-slug

Pirex360
  • 328
  • 2
  • 14
  • In some of the instalation guides in the docs about php frameworks this issue is talked about. Mostly because many frameworks have a folder structure that needs this workaround. You can create the symlink from your machine or inside the container using the ./shell.sh script provided in devilbox. – marcogmonteiro Nov 16 '20 at 10:00