[Bug] Docker compose, using local volume to sync folders removes all project files inside of the container
Describe the bug
when using docker compose to run the project, and when using the local volume sync in order to modify some features of the app, the project files inside of the container will be cleared. this issue is not present when using top level volumnes in the compose file.
here is the example with the issue :
fossbilling:
image: fossbilling/fossbilling:latest
restart: always
ports:
- 97:80
volumes:
- ./fossbilling:/var/www/html
here is the documentation compose file example (that works fine, but can't use ti to synchronize files between host and container)
version: "3.9"
services:
fossbilling:
image: fossbilling/fossbilling:latest
restart: always
ports:
- 97:80
volumes:
- fossbilling:/var/www/html
volumes:
fossbilling:
How to reproduce
use the above compose files to observe the issue
Expected behavior
synchronized project files, where the container files will be synchronized to the host to enable easy change
Screenshots
No response
FOSSBilling version
latest docker image
FOSSBilling instance ID
No response
Module version
No response
Device
Desktop
Information
macOS 12.1 Chrome for mac
Additional context
No response
This is due to how the Dockerfile is configured. It doesn't pull changes, each version is pre-built with the source code. As a result, binding the /var/www/html directory to a host directory causes it to lose the files. If you manually pull the files into your mapped directory before launching the container, it should work as expected.
The only realistic workaround would be to check the directory on container start, and if it's empty, pull the files directly (perhaps using the respective tag as a version indicator), or print an error to the user informing them of the issue. The latter probably makes more context given the current build pipeline.
I see, we could really use another way of deploying the app, that at least allows the update of the custom invoice PDF template,
i tried to use the top elvel volume then copy the files onto my directory (using docker cp) then switching to the sync folder config, but it didn't work, this was the error when openign the home page:
Fatal error: Uncaught Error: Class "FOSSBilling\ErrorPage" not found in /var/www/html/load.php:206 Stack trace: #0 [internal function]: exceptionHandler(Object(Exception)) #1 {main} thrown in /var/www/html/load.php on line 206
i will try to pull the base code and build it locally, as the next step
I see, we could really use another way of deploying the app, that at least allows the update of the custom invoice PDF template, i tried to use the top elvel volume then copy the files onto my directory (using
docker cp) then switching to the sync folder config, but it didn't work, this was the error when openign the home page:Fatal error: Uncaught Error: Class "FOSSBilling\ErrorPage" not found in /var/www/html/load.php:206 Stack trace: #0 [internal function]: exceptionHandler(Object(Exception)) #1 {main} thrown in /var/www/html/load.php on line 206i will try to pull the base code and build it locally, as the next step
Guessing either permissions got a little screwy or the line-endings got messed up (mixing Windows & Linux). Permissions are an easy fix by running this under your docker instance:
Either way, try giving this a go to verify the permissions didn't get messed up:
chown -R www-data:www-data /var/www/html*
cd /var/www/html
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
I don't personally use docker so I can't comment on the best way to edit things, but it should certainly be doable AFAIK.
My non-docker oriented brain would go to transferring it over using Filezilla & SSH or to log in via SSH and just copy & paste the desired contents into a nano window and save it that way.
@BelleNottelling I tried the commands to fix the permissions, but it didn't solve it. i am not sure if this is supposed to be the case, but the files on the host system have different ermissions than the ones in the container, and changing the permissions like you recommended from inside the container, doesn't change it on teh host side. I will try to get it to work locally and maybe build it differently
@moda20 for what it's worth, this structure does work for me. Just deploy the container, copy /var/www/html to your host, then rebuild the container with the mapped directory. I haven't needed to modify permissions at all, as I'm running the container with my own macOS user (presumably in the same way that you are), which permits the container's access