CyCoreSystems / docker-meteor

Dockerfile and script for running Meteor on Docker
MIT License
120 stars 73 forks source link

1.4 - Error: EISDIR: illegal operation on a directory, unlink '/home/meteor/src/app/.meteor/local/dev_bundle' #43

Closed Antoine-O closed 7 years ago

Antoine-O commented 7 years ago

Hello ! I am struggling with


meteor_1      | 1.4.2
meteor_1      | Building the bundle...(this may take a while)
meteor_1      | /home/meteor/.meteor/packages/meteor-tool/.1.4.2_3.17tso1e++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/meteor-promise/promise_server.js:190
meteor_1      |       throw error;
meteor_1      |       ^
meteor_1      |
meteor_1      | Error: EISDIR: illegal operation on a directory, unlink '/home/meteor/src/app/.meteor/local/dev_bundle'
meteor_1      |     at Error (native)
meteor_1      |     at Object.fs.unlinkSync (fs.js:932:18)
meteor_1      |     at exports.makeLink (/tools/cli/dev-bundle-links.js:20:8)
meteor_1      |     at [object Object].ensureDevBundleLink (/tools/project-context.js:1444:7)
meteor_1      |     at [object Object]._readFile (/tools/project-context.js:1378:10)
meteor_1      |     at new exports.ReleaseFile (/tools/project-context.js:1328:8)
meteor_1      |     at /tools/cli/main.js:898:22

FYI files :

meteor_1      | drwxr-xr-x   2 meteor staff  4096 Nov 18 17:36 dev_bundle
meteor_1      | lrwxrwxrwx   1 meteor meteor  129 Jan 21 23:55 dev_bundle-0ydfgxf5ia6mvx6r -> /home/meteor/.meteor/packages/meteor-tool/.1.4.2_3.17tso1e++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle
meteor_1      | lrwxrwxrwx   1 meteor meteor  129 Jan 21 21:00 dev_bundle-6l956y9kmcjif6r -> /home/meteor/.meteor/packages/meteor-tool/.1.4.2_3.17tso1e++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle
meteor_1      | lrwxrwxrwx   1 meteor meteor  129 Jan 22 00:15 dev_bundle-ek5w63hf84u0udi -> /home/meteor/.meteor/packages/meteor-tool/.1.4.2_3.17tso1e++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle
meteor_1      | lrwxrwxrwx   1 meteor meteor  129 Jan 22 00:47 dev_bundle-ujlfxas5ozcfecdi -> /home/meteor/.meteor/packages/meteor-tool/.1.4.2_3.17tso1e++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle
meteor_1      | lrwxrwxrwx   1 meteor meteor  129 Jan 22 00:12 dev_bundle-un9xx0ibdkmon7b9 -> /home/meteor/.meteor/packages/meteor-tool/.1.4.2_3.17tso1e++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle
meteor_1      | lrwxrwxrwx   1 meteor meteor  129 Jan 22 00:00 dev_bundle-wyht7ywjkq4ims4i -> /home/meteor/.meteor/packages/meteor-tool/.1.4.2_3.17tso1e++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle
meteor_1      | drwxr-xr-x   4 meteor staff  4096 Jan 21 20:57 isopacks
meteor_1      | drwxr-xr-x 302 meteor staff  4096 Jan 21 20:57 plugin-cache
meteor_1      | -rwxr-xr-x   1 meteor staff  9860 Jan 21 19:07 resolver-result-cache.json

any guess ?

Ulexus commented 7 years ago

I suspect that those symlinks are outside the filesystem of the container... but what arguments are you running docker with?

Antoine-O commented 7 years ago

nothing special. It happens at the last meteor upgrade :'(

i use a docker compose file

 meteor:
    build:
      context: ./meteor
      dockerfile: Dockerfile
    environment:
      - MONGO_URL=mongodb://xxxx
      - ROOT_URL=http://ccccc
      - MAIL_URL=smtp://sssss:25
      - SETTINGS_FILE=/home/meteor/settings.json

dev_bundle directory seems not to be writable...

each time I restart a new folder "dev_bundle-XXXXXXX" is created

Antoine-O commented 7 years ago

I am programming on Window. It may causes this inconsistency I think

Antoine-O commented 7 years ago

yup the link dev_bundle is bad -> 22/01/2017 13:38 dev_bundle [C:\Users\XXXXX\AppData\Local.meteor\packages\meteor-tool\1.4.2_3\mt-os.windows.x86_32\dev_bundle] it mays cause an error ;) anyone know the linux link ?

Ulexus commented 7 years ago

If it was working before the the last meteor upgrade, then chances are that it is related to the permissions model change.

Meteor dropped support for running as root, which, while good practice, makes life a bit more interesting for containers with bind-mounted data directories with unaffiliated and unpredictable permissions.

I suspect that on Windows, the chmod we perform before dropping root privileges has no effect. Unfortunately, I don't have a clue as to how the permissions model maps in a Windows environment. You might try setting global write permissions for that directory as a test.

Antoine-O commented 7 years ago

I find somehow to deal with that (i think) by generating a temporary project to get the right link.

and then :

Error: EXDEV: cross-device link not permitted, rename '/home/meteor/www/bundle' -

:/

Ulexus commented 7 years ago

Correct; you cannot make hard links across devices, and you can't use a symlink across the container boundary. I would start with a real, direct copy first... then try to back out and see if you can find some form of bind mounting that works with whatever your Windows filesystem setup is.

Antoine-O commented 7 years ago

ok there I finally succeeded ! But I completely remove whats in the dockerfile to concentrate on "my useful part" : creating an image from src

FYI I compile the meteor application during the creation of the image and the size is acceptable (around 583 MB) and here is the intersting part of the Dockerfile

RUN apt-get update && \
    apt-get upgrade -y && \
    apt-get install -y git curl && \
    (curl https://deb.nodesource.com/setup_4.x | sh) && \
    apt-get install -y nodejs jq && \
    apt-get install -y build-essential && \
    npm install -g semver && \
    apt-get clean && \
    rm -Rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
    setcap 'cap_net_bind_service=+ep' /usr/bin/nodejs && \
    cd /home/meteor && \
    (curl https://install.meteor.com/ | sh) && \
    meteor create test --bare && \
    cd /home/meteor/test && \
    meteor npm install && \
    cp -rf /home/meteor/test/.meteor/local  /home/meteor/src/.meteor/local && \
    cd /home/meteor/src && \
    meteor npm install && \
    meteor npm install --save babel-runtime && \
    meteor npm install --save xmlhttprequest && \
    meteor npm install --save bcrypt && \
    meteor npm install --save meteor-node-stubs && \
    cd /home/meteor/src && \
    mkdir -p /home/meteor/build && \
    meteor build --directory /home/meteor/build && \
    cd /home/meteor/build/bundle/programs/server  && \
    npm install && \
    npm install --save babel-runtime && \
    npm install --save xmlhttprequest && \
    npm install --save bcrypt && \
    rm -rf /home/meteor/src && \
    rm -rf /home/meteor/test && \
    rm -rf /usr/local/bin/meteor && \
    rm -rf /root/.meteor && \
    apt-get remove -y git curl && \
    apt-get remove -y build-essential && \
    apt-get autoremove -y && \
    apt-get clean && \
    rm -Rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

it may not be optimized BTW, it is so long to build an image so... I give up as soon as it worked :)

Ulexus commented 7 years ago

I'm glad you got it working. I would guess the critical difference is that you aren't bind-mounting anything, in your solution. This should have also been achievable by using a URL-sourced build tarball ( the BUNDLE_URL environment variable) or by pulling the source from a git repository (the REPO environment variable)

Antoine-O commented 7 years ago

sure, as I am on windows, I am not able to create the right bundle , right ?

Ulexus commented 7 years ago

I don't think that's a problem, no. Assuming Meteor works at all on Windows, you should be able to create a bundle for it.

To use BUNDLE_URL: Step 1: create a bundle of your app from your workstation (no Docker involved) Step 2: copy that bundle to some HTTP-accessible location Step 3: run ulexus/meteor with docker, passing the BUNDLE_URL environment variable pointing to the HTTP-accessible location

To use REPO: Step 1: store your application's source tree to a git repository Step 2: run ulexus/meteor with docker, passing the REPO environment variable pointing to the git repository's HTTP endpoint