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

Where / how to store persistent files from the docker image #454

Open
4shaw opened this issue May 29, 2015 · 13 comments
Open

Where / how to store persistent files from the docker image #454

4shaw opened this issue May 29, 2015 · 13 comments

Comments

@4shaw
Copy link

4shaw commented May 29, 2015

Hi... Im trying to save persistent files that can be served via nginx.
I cant save to the public directory as this is always overwritten on deploy.
Im trying to write to the file system with:
fs.writeFile('static/', ...)
this lands up on the host in: /opt/appname/current/bundle/programs/server/static
This gets overwritten on every deploy
then i tried:
fs.writeFile('/static/path', ...) Note the preceeding '/'
Im not sure where these files are... probably in the docker container?

Is there no volume on the container to store images etc that will persist through the deployment process
How would you go about doing this?
Thanks

Possible solution could be to add a volume for these files on the meteorhacks/meteord:base image?
Currently:
"Volumes": {
"/bundle": "/opt/appname/current"
},
To:
"Volumes": {
"/bundle": "/opt/appname/current",
"/static": "/opt/appname/static"
},

@4shaw 4shaw changed the title Where / how to store images from the docker image Where / how to store persistent files from the docker image May 29, 2015
@hems
Copy link

hems commented May 30, 2015

@4shaw this is something i would like to understand as well!

  • 1

in the meanwhile, if you just saving images an interesting workaround might be to use http://cloudinary.com which would host them in a CDN and give you transformations via url.

i found this meteor package that might be useful: https://github.com/Lepozepo/cloudinary

@mmoyles87
Copy link

I've just been using S3 personally. It's very inexpensive, and cloud storage seems to jive well with the docker philosophy.

On Sat, May 30, 2015 at 4:40 PM, henrique matias notifications@github.com
wrote:

@4shaw https://github.com/4shaw this is something i would like to
understand as well!

  • 1

in the meanwhile, if you just saving images and interesting workaround
might be to use http://cloudinary.com which would host them in a CDN and
give you transformations via url.

i found this meteor package that might be useful:
https://github.com/Lepozepo/cloudinary


Reply to this email directly or view it on GitHub
zodern/meteor-up#454 (comment).

Matt Moyles
http://mattmoyles.com

@hems
Copy link

hems commented May 31, 2015

@dubvfan87 indeed, but sometimes you sont want to trust your files to other hosts ( :

@4shaw
Copy link
Author

4shaw commented Jun 1, 2015

Thanks for the suggestions.
I agree with hems that there needs to be a solution local storage too.

I have tested by downloading the mupx repo and adding the volume for storage and it works. I called it "static"

The new directory structure at /opt/-appname-/ looks like:

config/
current/
last/
static/
tmp/

The static/ directory has been added and is not affected during deployment process... from within meteor you can access the static directory as though it were a root directory:
/static/-subfolder-/image.jpg

Then with nginx you can create an alias to point to to your static directory at:
/opt/-appname-/static

It would be cool if the meteor up team could consider adding this to the mupx branch so that we could start using it.

@jowilhnson
Copy link

Are there any other solutions to allow us to write to the filesystem? We have meteor apps running on a server in our intranet, one of which after updating required mupx to get redeployed. It builds PDFs and writes them to a shared folder in the filesystem. Or it used to anyhow, now it throws an "Error: ENOENT, open '/..../...pdf'" exception.

Editing the mupx repo, installing/configuring nginx etc is all a bit much for us just to be able to write files to the filesystem, so hoping there's a simpler workaround.

@MasterJames
Copy link

I'm thinking you could mount a volume with a change to the docker run command.

Here is an interesting thread as well.
zodern/meteor-up#458

It's this start.sh file that is where docker container is run with other volume mount entries.
https://github.com/arunoda/meteor-up/blob/mupx/templates/linux/start.sh

You could also I imagine use docker exec to execute the nessecary commands after mupx is done from ssh possibly.

The new port underway at kadirahq may have an option for that? Or a request there might be warranted.

@4shaw
Copy link
Author

4shaw commented Aug 2, 2016

Hi... sorry for the delayed reply

I can't remember everything I did to get it to work but I have the files on
Bitbucket... you use it exactly the same as mupx but with mup4 instead

eg:
mup4 deploy
etc....

You can clone the repo with the below url:
https://b4shaw@bitbucket.org/b4shaw/mup4.git

I just install mup4 from the directory like this:

npm install -g

its outdated now im sure but it still work well for me

On Sun, Jul 31, 2016 at 9:18 PM, Zachary Botterman <notifications@github.com

wrote:

@4shaw https://github.com/4shaw I know this is a bit late but I'd like
to try your method. Where can I add the additional volumes to add? I'd like
to replicate your "static" directory structure


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
zodern/meteor-up#454 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AH4MIog6ak98LZvJsq7WVIhMZwl6Y4pqks5qbPT2gaJpZM4EvAbM
.

@popaprozac
Copy link

popaprozac commented Aug 2, 2016

@4shaw No problem! I deleted my comment because I found a sustainable solution for me.

Found mupx directory in /usr/local/lib/node_modules/mupx and modified the following:

templates/linux/start.sh added:
--volume=$APP_PATH: / \

scripts/linux/setup-env.sh added:
sudo mkdir -p /opt/<%= appName %>/static

I had to rerun mupx setup and deploy.

The static directory is now accessible and persistent!

@greenwolfe
Copy link

zb0t, can you explain a little more about what you did? How does your volume command end up pointing to your static directory? Where/how is APP_PATH set, in your settings.json file? I assume you could make your static directory manually, but found it easier to automate it?

THanks,

Matt

@popaprozac
Copy link

popaprozac commented Aug 7, 2016

@greenwolfe I have a typo!
It should be:
--volume=$APP_PATH:/home \

It is accessible at /home/static.

I had issues not adding a base director, i.e. home. So that is why you see that prefixing static.

Notice in templates/linux/start.sh the top two lines:

APPNAME=<%= appName %> APP_PATH=/opt/$APPNAME

You could make the directory manually but in case I change my deployment location, this will be setup correctly every time.

Hope this helps.

@greenwolfe
Copy link

greenwolfe commented Aug 8, 2016

Thanks for the help! I got it working with the help also of issue235 from the meteor-uploads package.

@romaroma
Copy link

mup now supports 'volumes' option in mup.js
It seems to be a solution to the problem.
Just make a directory on your server, say /opt/APPNAME/uploads and map it to some directory in your docker - /opt/uploads or so.

@greenwolfe
Copy link

Still using meteor@1.1 and plan to stay that way for this year until things settle down some more. There are only so many times I can afford to completely rewrite my code. When I tried the lastest mup, it did not work with my version of meteor, so mupx with the hack for volumes is my best option until next summer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants