2017-01-30 9 views
3

ノードアプリケーションをドッキングしようとしています。私の現在のアプリケーションは、postgresqlを備えたnodejs expressサーバです。 ExpressJSは、ノード・サスミド・ミドルウェアを使用して、Sassアセットを処理します。 OSXマシンでnodeとpostgresqlをローカルに実行すると、すべて正常に動作します。私はdocker-composeでアプリケーションを実行しようとすると、私は「行方不明バインディングエラー」を取得node-sassとDockerの問題

ここに私のDockerfileです:私はドッキングウィンドウを実行すると

version: '2' 
services: 
    db: 
     image: postgres:9.6.1 
     ports: 
     - '5432:5432' 
    web: 
     build: . # use the Dockerfile next to this file 
     volumes: 
     - .:/my_app 
     ports: 
     - "3000:3000" 
     depends_on: 
     - db 

:ここ

FROM node:7.2.1 
RUN apt-get update -qq && apt-get install -y build-essential 
RUN apt-get install -y libpq-dev postgresql-client 
ENV APP_HOME /my_app 
RUN mkdir $APP_HOME 
WORKDIR $APP_HOME 
ADD package.json . 
RUN npm install 
RUN npm rebuild node-sass 
ADD . . 
CMD [ "npm", "start" ] 
EXPOSE 3000 

は私docker-compose.ymlファイルです次のエラーが表示されます。

web_1 | [nodemon] 1.11.0 
web_1 | [nodemon] to restart at any time, enter `rs` 
web_1 | [nodemon] watching: *.* 
web_1 | [nodemon] starting `node ./bin/www` 
web_1 | /my_app/node_modules/node-sass/lib/binding.js:15 
web_1 |  throw new Error(errors.missingBinary()); 
web_1 |  ^
web_1 | 
web_1 | Error: Missing binding /my_app/node_modules/node-sass/vendor/linux-x64-51/binding.node 
web_1 | Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 7.x 
web_1 | 
web_1 | Found bindings for the following environments: 
web_1 | - OS X 64-bit with Node.js 7.x 
web_1 | 
web_1 | This usually happens because your environment has changed since running `npm install`. 
web_1 | Run `npm rebuild node-sass` to build the binding for your current environment. 
web_1 |  at module.exports (/my_app/node_modules/node-sass/lib/binding.js:15:13) 
web_1 |  at Object.<anonymous> (/my_app/node_modules/node-sass/lib/index.js:14:35) 
web_1 |  at Module._compile (module.js:571:32) 
web_1 |  at Object.Module._extensions..js (module.js:580:10) 
web_1 |  at Module.load (module.js:488:32) 
web_1 |  at tryModuleLoad (module.js:447:12) 
web_1 |  at Function.Module._load (module.js:439:3) 
web_1 |  at Module.require (module.js:498:17) 
web_1 |  at require (internal/module.js:20:19) 
web_1 |  at Object.<anonymous> (/my_app/node_modules/node-sass-middleware/middleware.js:3:12) 
web_1 |  at Module._compile (module.js:571:32) 
web_1 |  at Object.Module._extensions..js (module.js:580:10) 
web_1 |  at Module.load (module.js:488:32) 
web_1 |  at tryModuleLoad (module.js:447:12) 
web_1 |  at Function.Module._load (module.js:439:3) 
web_1 |  at Module.require (module.js:498:17) 
web_1 | [nodemon] app crashed - waiting for file changes before starting... 

DockerfileにRUN npm rebuild node-sassを追加することで、ドッキング・コンテナ内のOS用の正しいバインディングが構築されます...しかし、動作していないようです。

どのような考えですか?

+0

インストールしようとしているnode-sass-middleware/node-sassのバージョンは次のとおりです。ノード7のサポートは準最近追加されました – nschonni

+0

@nschonni私はnode-sass-middlewareバージョン0.9.8を使用しています – jubeless

答えて

5

node-sass v3.7.0にNode.js 7(LinuxおよびOSX用)のサポートが追加されているようです。これ以上のバージョンを使用してください。

どちらかあなたのDockerfile更新することができますのためのさまざまなバージョンに目を光らせておいてください

cd /path/to/node_app/node_modules 
mkdir -p node-sass/vendor/linux-x64-51 
curl -L https://github.com/sass/node-sass/releases/download/v4.5.0/linux-x64-51_binding.node -o node-sass/vendor/linux-x64-51/binding.node 

FROM node:7.2.1 
RUN apt-get update -qq && apt-get install -y build-essential 
RUN apt-get install -y libpq-dev postgresql-client 
ENV APP_HOME /my_app 
RUN mkdir $APP_HOME 
WORKDIR $APP_HOME 
ADD package.json . 

# Add the two entries below 
RUN mkdir -p node_modules/node-sass/vendor/linux-x64-51 
RUN curl -L https://github.com/sass/node-sass/releases/download/v4.5.0/linux-x64-51_binding.node -o node_modules/node-sass/vendor/linux-x64-51/binding.node 

RUN npm install 
RUN npm rebuild node-sass 
ADD . . 
CMD [ "npm", "start" ] 
EXPOSE 3000 

をそれとも、そのままDockerfileからローカルに結合ダウンロードして構築することができますhttps://github.com/sass/node-sass/releases

+0

私はバインディングファイルをローカルで取得し、Dockerfileからビルドすることができます。 : 'web_1 |エラー:/my_app/node_modules/node-sass/vendor/linux-x64-51/binding.node:無効なELFヘッダー ' 考えますか? – jubeless

+0

バイナリリポジトリに物を引っ張ってはいけません。メンテナのためのスクラッチパッドです。バイナリをカールしようとしている場合は、GHの添付ファイルを使用してください。 – nschonni

+0

私はGHリリースのリンクを使って答えを更新しました。 –

関連する問題