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

Add Dockerfile for image, and a docker-compose setup #76

Open
wants to merge 2 commits into
base: vk-api
from

Conversation

@HugoPoi
Copy link

commented Sep 30, 2018

Dockerify the app for deployment

  • The base image is the official php-fpm-alpine
  • I'm not an expert in Docker stuff
  • The php container run as datmusic user for better security. The code is readonly owned by root.
  • Only storage is writable.
  • I provide a docker-compose with a minimal nginx frontend setup.

Some issue that can be annoying

  • There is an issue with symlinks in app/links storage folder created in absolute way. This prevent using an another path in the frontend webserver that the one in the php container. This issue need some php code change. I can do a proposal for that.

Other notes

  • I may add Redis in docker-compose configuration.
  • I may need to mount only public storage in the nginx container, but I cannot find a simple way of doing this (maybe split storage public vs other stuff) not critical
  • Logs are not configured properly ! We need all logs to be redirected to stdout or stderr for the php container I think. ( Some logs are created in storage/logs )
@alashow

This comment has been minimized.

Copy link
Owner

commented Sep 30, 2018

Hey. Thanks for your contribution!

I tried testing it, but something is wrong with nginx config. opening host/ returns nginx's 403 error and opening host/search return nginx's 404. error.

Can you elaborate on app/links problem? It's probably related to it, as nginx config looks unusual because of it. We can fix it before merging this.

@alashow alashow force-pushed the alashow:vk-api branch 9 times, most recently from 63381c6 to 7afc010 Oct 11, 2018

@HugoPoi

This comment has been minimized.

Copy link
Author

commented Apr 7, 2019

Hi @alashow , has been a while,
I think i fix the 404 issue you have.

And for the path problem it related from the way of link are created like
'some title.mp3' -> /usr/src/datmusic/storage/app/public/mp3/f5e188443fd633fec7e3902b830ca499.mp3
After the symlink is created, the app send a HTTP redirection to links which is handle by nginx for serving the file. Nginx running in a different container so when it need to serve the file it look in the symlink for resolving to the real file, so for the path to be resolved correctly we can't have storage volume mounted on /var/datmusic for exemple but MUST be mounted in the exact same location as in the php container. It's not a big constraint but it couple the params of the nginx image with the app image.

The simple fix is to create the symlink with relative path to storage like
'some title.mp3' -> ../../mp3/f5e188443fd633fec7e3902b830ca499.mp3

Only this line need to be change.
https://github.com/alashow/datmusic-api/blob/vk-api/app/Datmusic/DownloaderTrait.php#L376-L381

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.