DEV Community

Akbar Nafisa
Akbar Nafisa

Posted on

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

Top comments (0)