Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Docker compose, using local volume to sync folders removes all project files inside of the container #2064

Open
moda20 opened this issue Jan 13, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@moda20
Copy link

moda20 commented Jan 13, 2024

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

@moda20 moda20 added the bug Something isn't working label Jan 13, 2024
@moda20 moda20 changed the title [Bug] Docker compose, using local volume folders removes all project files inside of the container [Bug] Docker compose, using local volume to sync folders removes all project files inside of the container Jan 13, 2024
@wolveix
Copy link
Contributor

wolveix commented Jan 13, 2024

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.

@moda20
Copy link
Author

moda20 commented Jan 13, 2024

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

@BelleNottelling
Copy link
Member

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

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.

@moda20
Copy link
Author

moda20 commented Jan 14, 2024

@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

@wolveix
Copy link
Contributor

wolveix commented Jan 14, 2024

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants