Search code examples
node.jsdockerstrongloopwercker

Expose Port for App via wercker.yml


I've configured my wercker.yml to use a NodeJS box and install StrongLoop and run npm-install as follows:

box: nodesource/node:trusty
build:
  steps:
    - script:
        code: |
          npm install -g strongloop
    - npm-install

I'd like to take the resulting container, run it on my server, and launch my app. However, by default the needed port (3000) is not exposed when I download and run the container. Is there a way for me to expose this port via wercker config, or will I need to either prepare my own box with StrongLoop and port 3000 exposed for use in wercker or use the resulting container from wercker and use a Dockerfile to expose it after. Thanks in advance.


Solution

  • It appears that at this time, wercker does not support configuring this aspect of the container/image.

    That said, it isn't necessary to configure exposed ports in the image itself since you can do that at run/launch time:

    docker run --detach --publish 3000:3000 --env PORT=3000 image-name
    

    The above exposes port 3000 and sets the $PORT environment variable inside the container to 3000, which is a common way of telling the app to listen on port 3000.