Prepare Your Application for Deployment
To deploy an application, you’ll need to create a couple of configuration files: a Dockerfile and a Docker Compose file. These tell the platform how to build and run your app. Once that’s done, you’ll package your app into a Docker image and upload it to a container registry — making it easy for the Mesh of Things platform to deploy it wherever it needs to go.
TIP
There are some pre-defined Docker Compose files in your Dashboard to get started quickly.
If you are unfamiliar with containers there are tons of resources out there and ChatGPT will also do a great job of writing one for you. Below we will also guide you through the basics.
At the end of this page, there are also some useful resources to learn more about Docker files and Docker Compose if you require more help.
Step 1: Create a Dockerfile
The first step in preparing your application for deployment is to create a Dockerfile. A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. The Dockerfile is used to build a Docker image, which is a lightweight, standalone, executable package of software that includes everything needed to run a piece of software, including the code, a runtime, libraries, environment variables, and config files.
Here is an example of a simple Dockerfile:
# Use the official Python image from the Docker Hub
FROM python:3.11-slim
# Copy the current directory contents into the container at /app
COPY . /app
# Install any necessary dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Make port 80 available to the world outside this container
EXPOSE 80
# Run app.py when the container launches
CMD ["python", "app.py"]This example assumes you have a Python application with a requirements.txt file and an entry script called app.py alongside the Dockerfile. Modify the Dockerfile as needed to fit your application’s specific requirements.
Alternatively, there are many pre-built Docker images available on Docker Hub that you can use as a base image. For example, you can run an NGINX server with the following Dockerfile:
# Use the official NGINX image from the Docker Hub
FROM nginx:latest
# Copy the current directory contents into the container at /usr/share/nginx/html
COPY . /usr/share/nginx/html
# Expose port 80
EXPOSE 80This example uses the official NGINX image as a base and copies the current directory contents into the container at /usr/share/nginx/html, which is the default location for NGINX to serve files.
Step 2: Build and Push Your Docker Image
With your Dockerfile prepared, the next step is to build your Docker image and push it to a container registry like Docker Hub. This makes the image accessible for deployment across your Mesh of Things (MoT) network.
Build the Docker Image
Navigate to your application’s root directory (where the Dockerfile is located) and run the following command, where yourusername is your container registry username and your-app-name is the name of your application:
docker build -t yourusername/your-app-name:latest .Replace yourusername/your-app-name with a suitable name corresponding to your Docker Hub (or other registry) account and project. You can also tag the image with a specific version instead of latest, e.g., :v1.0.0.
Push to a Container Registry
Ensure you’re logged in to your container registry:
docker loginTIP
If you’re using a different container registry like GitHub Container Registry or Google Container Registry, make sure to configure your credentials and URLs accordingly.
Then push the image:
docker push yourusername/your-app-name:latestOnce the image is in the registry, it’s ready to be referenced during deployment in your Compose file through the Mesh of Things platform.
Step 3: Create a Docker Compose File
Docker Compose allows you to define and manage multi-container applications in a single yaml file.
Here’s a basic example:
services:
web:
image: yourusername/your-app-name:latest
ports:
- '80:80'
environment:
- ENV=production
restart: unless-stoppedKey Elements:
- image: The image you previously pushed to the registry.
- ports: Maps container ports to host ports (e.g., 80:80).
- environment: Use this to set environment variables required by your application.
- restart: Optional restart policy.  
If your application depends on other services, like a database, you can define them too:
services:
web:
image: yourusername/your-app-name:latest
ports:
- '80:80'
db:
image: postgres:17
environment:
POSTGRES_USER: user
POSTGRES_PASSWORD: passwordMake sure to replace the configuration values with your own application-specific requirements.
Once your Docker Compose file is ready, you’re all set to proceed to deployment using Mesh of Things. Open your dashboard and use your Docker Compose file to define an application to deploy to devices.
Learning More
If you want to learn more about Dockerfiles and Docker Compose, here are some helpful resources: