Add Portainer Stack

akbarnafisa

Akbar Nafisa

Posted on January 26, 2024

Add Portainer Stack

In this section, we will migrate our current deployment to Portainer so that we can fully manage it inside Portainer later on. You can view the full code for the configuration here. To migrate our app, let’s follow these steps:

Update Docker Compose

In Portainer, we can set up the environment in their dashboard. However, we need to make some adjustments, such as changing the file name of .env.prod to stack.env.

Image description

Next, we need to change how we mount the create_tables.sql. In our current implementation, we cannot directly mount the file; Docker will treat the create_tables.sql as a folder instead of a file. Therefore, we need to use a new Docker volume to mount the file.

Image description

Delete Existing Container

Moving on to the next part, we will delete our existing Docker container and Docker volumes.

Image description

Image description

Image description

Image description

Create New Stack

The next step is to create a new stack for our project. To do so, open the Stacks section in the dashboard and click the Add stack button. Then, add the GitHub repository URL, branch name, and the Docker Compose file.

Image description

The following step is to add the environment variables and click Deploy the stack to finish the configuration.

Image description

After completing the deployment, we can now have total control over our stack.

Image description

We can also check our API endpoint to ensure that everything is working as before.

Image description

💖 💪 🙅 🚩
akbarnafisa
Akbar Nafisa

Posted on January 26, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Add Portainer Stack
webdev Add Portainer Stack

January 26, 2024

Setup EC2 Instance
webdev Setup EC2 Instance

December 19, 2023

Setup CloudFront for Client App
webdev Setup CloudFront for Client App

January 4, 2024

Create Access Key for AWS S3
webdev Create Access Key for AWS S3

December 29, 2023