0
我建立一個碼頭工人形象有以下Dockerfile
FROM node:latest
RUN npm install -g gulp
# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Install app dependencies
COPY package.json /usr/src/app/
RUN npm install
# Bundle app source
COPY . /usr/src/app
EXPOSE 5000
CMD ["gulp", "serveprod"]
我知道我需要從Heroku的文檔暴露$PORT
變量。
但是,我不知道這是如何與吞嚥工作。
這是我的gulpfile.js
和serveprod
任務。
gulp.task('serveprod', function() {
connect.server({
root: './',
port: $PORT || process.env.PORT || 5000, // localhost:5000
livereload: false
});
});
以前,我用的是節點buildpack和所有我需要的是port:
和process.env.PORT
它會工作得很好。我曾嘗試添加$PORT
,但這仍然無法正常工作。
UPDATE:
我只是試圖把這個在我Dockerfile
ENV 5000 $PORT
這裏是Heroku的日誌:
2017-07-07T15:01:27.127275+00:00 heroku[web.1]: Starting process with command `gulp serveprod`
2017-07-07T15:01:29.985824+00:00 heroku[web.1]: State changed from starting to crashed
2017-07-07T15:01:29.875500+00:00 app[web.1]: module.js:487
2017-07-07T15:01:29.875515+00:00 app[web.1]: throw err;
2017-07-07T15:01:29.875517+00:00 app[web.1]: ^
2017-07-07T15:01:29.875517+00:00 app[web.1]:
2017-07-07T15:01:29.875518+00:00 app[web.1]: Error: Cannot find module './lib/_stream_readable.js'
2017-07-07T15:01:29.875519+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:485:15)
2017-07-07T15:01:29.875519+00:00 app[web.1]: at Function.Module._load (module.js:437:25)
2017-07-07T15:01:29.875520+00:00 app[web.1]: at Module.require (module.js:513:17)
2017-07-07T15:01:29.875521+00:00 app[web.1]: at require (internal/module.js:11:18)
2017-07-07T15:01:29.875539+00:00 app[web.1]: at Object.<anonymous> (/usr/local/lib/node_modules/gulp/node_modules/through2/node_modules/readable-stream/readable.js:12:30)
2017-07-07T15:01:29.875540+00:00 app[web.1]: at Module._compile (module.js:569:30)
2017-07-07T15:01:29.875541+00:00 app[web.1]: at Object.Module._extensions..js (module.js:580:10)
2017-07-07T15:01:29.875541+00:00 app[web.1]: at Module.load (module.js:503:32)
2017-07-07T15:01:29.875542+00:00 app[web.1]: at tryModuleLoad (module.js:466:12)
2017-07-07T15:01:29.875543+00:00 app[web.1]: at Function.Module._load (module.js:458:3)
2017-07-07T15:01:29.971237+00:00 heroku[web.1]: Process exited with status 1
2017-07-07T15:01:32.103467+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=www.christopherdbolton.com request_id=469ad736-103a-461f-af20-91454a8a83f1 fwd="139.72.158.28" dyno= connect= service= status=503 bytes= protocol=http
2017-07-07T15:01:32.923798+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=www.christopherdbolton.com request_id=a5c0b8c4-69c7-4bd7-ab00-372fe625b2f8 fwd="139.72.158.28" dyno= connect= service= status=503 bytes= protocol=http
Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect...
2017-07-07T15:01:29.875520+00:00 app[web.1]: at Module.require (module.js:513:17)
2017-07-07T15:01:29.875521+00:00 app[web.1]: at require (internal/module.js:11:18)
2017-07-07T15:01:29.875539+00:00 app[web.1]: at Object.<anonymous> (/usr/local/lib/node_modules/gulp/node_modules/through2/node_modules/readable-stream/readable.js:12:30)
2017-07-07T15:01:29.875541+00:00 app[web.1]: at Object.Module._extensions..js (module.js:580:10)
2017-07-07T15:01:29.875540+00:00 app[web.1]: at Module._compile (module.js:569:30)
2017-07-07T15:01:29.875541+00:00 app[web.1]: at Module.load (module.js:503:32)
2017-07-07T15:01:29.875542+00:00 app[web.1]: at tryModuleLoad (module.js:466:12)
2017-07-07T15:01:29.875543+00:00 app[web.1]: at Function.Module._load (module.js:458:3)