Clouddley Documentation
  • 👋Welcome to Clouddley Documentation.
  • ⚡CLOUDDLEY TRIGGR
    • Triggr Apps
      • 🛠️How-to Guides
        • 📗Deploy a Ruby on Rails App on Clouddley Triggr
        • 📔Deploy a Flask Application on Clouddley Triggr
        • 📙Deploy a .NET Core Application on Clouddley Triggr
        • 📔Deploy a FastAPI App on Clouddley Triggr
        • 📕Deploy a NestJs App on Clouddley Triggr
        • 📙Deploy a Go Application on Clouddley Triggr
        • 📗Deploy a Laravel App on Clouddley Triggr
        • 📓Deploy a Next.js App on Clouddley Triggr
        • 📘Deploy an Express.js Application on Clouddley Triggr
      • 🛠️Extras
        • 🔔Notifications
        • ⚙️Environment Variables
        • 🌐Custom Domain
        • How to Rollback an Application
        • ⏯️How to Pause and Resume Applications
        • Scale applications on Clouddley Triggr
        • 📕Deploy an Application with a Dockerfile on Clouddley Triggr
  • Triggr Databases
    • 🛠️How-to Guides
      • Deploy a MongoDB Database on Clouddley Triggr
      • Deploy a MariaDB Database on Clouddley Triggr
      • Deploy a PostgreSQL Database on Clouddley Triggr
      • Deploy a Redis Database on Clouddley Triggr
      • Deploy a MySQL Database on Clouddley Triggr
    • 🛠️Extras
      • Database Networking on Clouddley Triggr
      • 🔁How to Reset Database Password on Clouddley Triggr
Powered by GitBook
On this page
  • Prerequisites
  • Creating a Dockerfile
  • Building and Running the Container Locally
  • Deploying the Application
  • Conclusion

Was this helpful?

  1. CLOUDDLEY TRIGGR
  2. Triggr Apps
  3. Extras

Deploy an Application with a Dockerfile on Clouddley Triggr

Learn how to deploy an application using a Dockerfile on Triggr.

PreviousScale applications on Clouddley TriggrNextTriggr Databases

Last updated 2 months ago

Was this helpful?

Deploying applications with a Dockerfile on Clouddley Triggr allows you to containerize and manage your application efficiently. This guide provides step-by-step instructions on deploying an Express.js application using a Dockerfile, ensuring a seamless and reliable deployment process.

Prerequisites

  • A or Account.

  • A account.

  • Basic understanding of .

  • An application.

  • A virtual machine on a Cloud platform or bare metal server.

Creating a Dockerfile

In the application root directory, create a Dockerfile triggr.dockerfile that defines how the app should be containerized.

Best Practice: When creating a Dockerfile, use a lightweight base image (e.g., node:alpine for Node.js apps) to reduce image size. Always specify exact versions for dependencies to ensure consistency.

triggr.dockerfile
# Use an official Node.js runtime as a parent image
FROM node:18-alpine

# Set the working directory in the container
WORKDIR /app

# Copy package.json and package-lock.json first for dependency installation
COPY package*.json ./

# Install dependencies
RUN npm install --omit=dev  # Use --omit=dev for production builds

# Copy the rest of the application code
COPY . .

# Expose the application port (ensure it matches the port your app listens on)
EXPOSE 3011

# Define the command to run the application
CMD ["node", "./bin/www"]

Building and Running the Container Locally

Before deploying to Triggr Apps, verify that the container works locally.

  1. Build the Docker image:

    docker build -t my-express-app -f triggr.dockerfile .
  2. Run the container:

    docker run -d -p 3011:3011 --name express-container my-express-app
  3. Verify the app is running by visiting http://localhost:3011.

Deploying the Application

Accessing Clouddley Triggr

  • Open your web browser, log in to your Clouddley account

Step 1: Configure Service

  • Choose your Git hosting service; either GitHub or Bitbucket. For this tutorial, we will be using GitHub.

  • Click on Continue with GitHub

Step 2: Configure Git

  • To connect your GitHub user or organization account, click the Select username/organization dropdown and Add GitHub account.

  • Select your repository and the branch from the dropdown list or quickly search.

  • Click on NEXT

Step 3: Configure your Virtual Machine

  • To configure your VM, insert your VM hostname or IP address, VM user, and the VM port for SSH access.

  • Use the Clouddley CLI (recommended) or connect via SSH to verify.

The Clouddley CLI is a command-line tool that allows you to interact with the Clouddley Platform from your terminal.

  • Open the command line of the remote VM you want to configure to Clouddley and install Clouddley CLI by running the command:

curl -L https://raw.githubusercontent.com/clouddley/cli/main/install.sh | sh
  • To install Triggr, run the command:

clouddley triggr install

Using the CLI, you can deploy resources, manage configurations, and automate tasks efficiently.

  • Download the public key to your local machine.

  • Run the provided command in your local machine allowing Triggr to connect to your virtual machine.

ssh-copy-id -f -i ~/path/to/downloaded/Publickey username@ipaddress

Replace ~/path/to/downloaded/Publickey ,username and ipaddress with your actual values.

  • Click on Verify. This verifies the connection.

  • Click on NEXT

Step 4: Configure app settings

Insert the name of the application and its port.

The firewall of the virtual machine should allow access to the application port.

Step 5: Configure Environment Variables

  • Add the key-value pairs and Click on Save

  • Click on NEXT

Step 6: Setup Notifications (optional)

  • Select the Alert type. For this tutorial, we will set up Email alerts.

  • Toggle on the buttons of the deployment event (failed, timed out, or success) you want to be notified of.

  • Enter the Email address where you want to receive alerts. (You can add multiple email addresses)

  • Click on Save

  • Click on Deploy

Step 7: Test and Verify the app

  • Click on Go to Dashboard. Your app will be visible on the Triggr apps dashboard.

  • After the app deployment is complete, the app status changes from deploying to running

  • You can test the application functionalities.

The Express.js application has been successfully deployed on Triggr with a Dockerfile. You can manage it from the application dashboard by selecting the three-dot menu (…) in the top-right corner, where you will find options to Edit, Instant Rollback, Scale, Pause, or Delete the deployment.

Additionally, you can navigate through the dashboard tabs to:

  • View deployment history

  • Access and download logs

  • Add a custom domain

  • View and manage environment variables

Conclusion

Navigate to and click on Deploy App.

To add environment variables, click on Add Variable

Choose an ENV mode, which can be either single or import variables. Learn more .

To configure the notification settings of the application, click on Add Alert

Click on Website at the top right corner of the page, this opens the URL of the deployed application in your browser.

Following these steps, you have successfully deployed an Express.js application with a Dockerfile on Clouddley Triggr. This method ensures a consistent, scalable, and efficient deployment workflow. Check out the source code for this application .

⚡
🛠️
📕
➕
➕
🌐
GitHub
Bitbucket
Clouddley
Docker
Express.js
Triggr Apps
here
here
Accessing Triggr Apps
Choose your Git hosting service
Setup the Express.js application repository on Triggr
Configuration of virtual machine on Triggr
Configure the App name and port
Single variable ENV mode
Import variables ENV mode
Adding environment variables
Notifications set up and creation of Express.js application on Triggr
Express.js application dashboard overview
Express.js application running from Triggr on a cloud virtual machine
Image of Triggr Apps dashboard.
Configuring Git hosting service during app deployment on Triggr Apps.
Configuring the Git repository during app deployment on Triggr Apps.
Configuring the virtual machine during app deployment on Triggr Apps.
Configuring App settings (name and port) during app deployment on Triggr Apps.
Image showing the single variable ENV mode on Triggr Apps
Image showing the Import Variables ENV mode on Triggr Apps.
Image showing environment variables added during app deployment on Triggr Apps.
A gif showing how to set up notifications on Triggr Apps.
An image of the overview of a successfully deployed Express.js application on Triggr Apps.
An image of the Express.js application running on Triggr on the web.