Reputation: 569
I'm trying to deploy an app to Heroku which was dockernized. This is my Dockerfile:
FROM node:4.2.2
WORKDIR /usr/src
RUN git clone https://github.com/***.git
WORKDIR /usr/src/application
RUN ./install.sh
EXPOSE 80 3000
CMD bash -C '/usr/src/application/start.sh'
Also, I have a Profile with just one line as follow:
web: node bin/www
Following the steps on the documentation, I've pushed the image via two commands:
heroku container:push web --app immense-falls-39679
and released with
heroku container:release web --app immense-falls-39679
.
In the logs, everything seems to be going ok, with the app deployed successfully. But when it is about to start (with the start.sh
script) it crashes with the error
2018-10-23T20:47:44.025502+00:00 app[web.1]: [20:47:44] Finished 'build-app' after 7.11 s
2018-10-23T20:47:44.025958+00:00 app[web.1]: [20:47:44] Starting 'bundle-release'...
2018-10-23T20:48:07.932228+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2018-10-23T20:48:07.932327+00:00 heroku[web.1]: Stopping process with SIGKILL
2018-10-23T20:48:08.058850+00:00 heroku[web.1]: Process exited with status 137
2018-10-23T20:48:08.097770+00:00 heroku[web.1]: State changed from starting to crashed
I've researched and most have said that this is due to fixed setting the PORT value. But, in my bin/www
(where is my server configs), I've already set the port to be either a fixed value or from the process.env
var app = require('../out/app');
var debug = require('debug')('server:server');
var http = require('http');
/**
* Get port from environment and store in Express.
*/
app.set('port', (process.env.PORT || 3000));
/**
* Create HTTP server.
*/
var server = http.createServer(app);
/**
* Listen on provided port, on all network interfaces.
*/
server.listen(app.get('port'), function() {
listenForNotificationRequests();
});
server.on('error', onError);
server.on('listening', onListening);
I dont have any other clues on how fixing it. I would really appreciate any help. Thanks in advance
Upvotes: 2
Views: 4088
Reputation: 148
To deploy a docker container to Heroku you'll need to adjust your Dockerfile to work with Heroku.
EXPOSE 80 3000
, because it is not used by Herokuprocess.env.PORT
. If you'd rather pass the port in the Dockerfile cmd then you can use CMD start_app_command -p $PORT
run heroku logs --tail
after deploying and you will see that $PORT is replaced with the port set by Heroku.
https://devcenter.heroku.com/articles/container-registry-and-runtime
Upvotes: 2