Deploy a Node.js application - Dockerfile

Your project needs to contain a dockerfile according to your project. You can generate one automatically with

openode template

Then to deploy, just run:

openode deploy

Your instance will be considered up if it listens to port 80.

See this template example. You can import it automatically by running openode template as described above.

See below an example Dockerfile from a template:

FROM node:8.12.0-alpine

WORKDIR /opt/app

ENV PORT=80

RUN touch /usr/bin/start.sh # this is the script which will run on start

# if you need a build script, uncomment the line below
# RUN echo 'sh mybuild.sh' >> /usr/bin/start.sh

# if you need redis, uncomment the lines below
# RUN apk --update add redis
# RUN echo 'redis-server &' >> /usr/bin/start.sh

# daemon for cron jobs
RUN echo 'echo will install crond...' >> /usr/bin/start.sh
RUN echo 'crond' >> /usr/bin/start.sh

RUN echo 'npm install --production' >> /usr/bin/start.sh

# npm start, make sure to have a start attribute in "scripts" in package.json
RUN echo 'npm start' >> /usr/bin/start.sh

Note that it is creating a starting script file (/usr/bin/start.sh) which we execute automatically when you deploy. Thus your deployment can be fully customized by editing this file.