Deploy dockerized apps using a Dockerfile on the NodeChef Cloud

Most applications on NodeChef can be deployed as is as we do support language buildpacks. In some applications, you might want to customize the image that runs your applications or have special build requirements. In such cases, NodeChef supports hosting your application with your own custom Dockerfile. Read more on our Docker hosting offering.

This tutorial document will walk you through creating an application on NodeChef and then deploying by either uploading your zipped project folder from the dashbaord, uploading using the CLI or deploy from your GitHub, Bitbucket or GitLab repository.

Dockerfile tips

You must specify a CMD instruction.

You can use the EXPOSE instruction to expose up to one port.

If you do not use expose, you can listen for connections using the environment variable PORT.

An example dockerized Node.js app

FROM node:14

# Create app directory
WORKDIR /usr/src/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

RUN npm install
# If you are building your code for production
# RUN npm ci --only=production

# Bundle app source
COPY . .

CMD [ "node", "server.js" ]
  • 1
    Create an app on NodeChef

    Log in and navigate to the Dashboard. Click on deployments and complete the form. You will be required to select the size of your container and the region where your cluster is to be hosted. You can also choose to create your app with a MySQL, MongoDB or PostgreSQL database.

    Once the cluster is provisioned, a URL will be assigned to your project which will be displaced on the dashboard.

    Create your application on NodeChef
  • 2
    Deploying your app.

    You can deploy your app to NodeChef cloud hosting by uploading your project folder as a zip, using GIT or the NodeChef CLI.

    Deploying your app by uploading your project folder.

    You must first zip all the contents in your project folder or use a tar archive with gzip compression to bundle all the files in your project folder. You can then upload this bundle.

    The zip or tar.gz archive cannot exceed 256 megabytes in size. You can always find the form to upload your project from the dashboard by navigating to the task manager → App actions → Upload code.

    Deploy by Uploading your the project folder of your dockerized app
    You can set your environment variables from the dashboard before deploying your app. You do not have to keep them in a JSON file as seen in the above image. See how to do so by clicking here.

    Once you click the Deploy app button, you should be able to see the status of the deployment from the progress indicator which is displayed right below the Upload form.

    Deploying your app from your GitHub, GitLab or BitBucket repository.

    Firstly, if you did not sign up for a NodeChef account using a GIT repo provider, you must authorize NodeChef to access your GitLab, GitHub or BitBucket account. You only have to do this once per NodeChef account. Click “Connect to (repository)”, a shown below to start the authentication.

    NodeChef select Git integration from Task manager NodeChef Github,Bitbucket & GitLab authorization

    After you link your Account to a Git repo, you can selectively deploy from branches as well.

    NodeChef Git repository

    As seen below, select the custom image after you click the Deploy current branch button.

    Build custom image from dockerfile

    Deploying your app using the NodeChef CLI.

    Install the NodeChef CLI from npm as showm below:

    npm install -g nodechef-cli

    CD into your project folder and use the below command as seen below. You will have to login from the command line to deploy or use a deployment token if you generated one from the dashboard.

    We advice you explicitly specify the switch [-bp] with the value dockerfile as seen below. This is because in most cases, your project folder also contains files such as package.json, Gemfile.lock etc that will result in the project been built with a buildpack instead of building using the dockerfile.
    nodechef login nodechef deploy -i my_first_app -bp dockerfile // If the dockerfile is not in the root folder, // specify the relative path to it as seen below: nodechef deploy -i my_first_app -bp dockerfile -dfdir v23/build/