Deploy a Full-Stack Application with Portainer
The Portainer container management software should be considered a must-have for container developers looking to enjoy the most efficient path to the deployment and management of their containerized applications. Portainer allows you to manage registries, images, networks, events, volumes, hosts, environments, logs, even full-stack applications.
That’s right, this web-based GUI isn’t limited to only single app deployments. With Portainer you can create a full-stack application and even assign that stack to teams.
And that’s exactly what I’m going to show you today: How to create a team, add users to the team, and then deploy a sample full-stack app that can be managed by the newly-created team.
To make this work, you’ll need a running instance of Portainer. And that’s it. You’re ready to make this work.
Adding Users to Portainer
The first thing we’ll do is add a user to Portainer (that will then be added to a team). To add the user, log into Portainer and click Users from the left navigation. In the resulting window (Figure 1), type the name of the new user and type/confirm a password for the user.
Since we’ve not added a team yet, don’t bother with the Add to team(s) drop-down and, instead, just click Create user.
Adding a Team to Portainer
After you’ve created the user, click on Teams in the left navigation. In the new window (Figure 2), type a name for the new team and then, from the team leader drop-down, select a user that will serve as the team leader.
Click Create team to save the new team. To then add more members to the team, click the name of the team under the Teams section. In the resulting page (Figure 3), click Add associated with all of the users you want to add to the team.
Deploying the Full-stack App
Okay, we now have users and teams added. It’s time to deploy that full-stack application. I’ve borrowed a sample full-stack app from this DockerHub repository which houses a number of really great samples you can use for various development and testing projects. You’ll find samples for deployments such as a voting app (the sample I’ll be demonstrating), a single container deployment, a simple web app, and even a Docker Swarm visualizer. This is a great way to learn how to work with everything from simple to complex deployments.
Back at the Portainer interface, click on Stacks in the left navigation. On that page (Figure 4), click Add stack.
In the next window (Figure 5), give the stack a name (in all lowercase).
You’ll want to select web editor (as we’re going to copy/paste our docker-compose file from the sample). If you’ve already crafted your full-stack application on your local machine, you can click Upload to add the docker-compose file to Portainer. If, however, you use a Git repository, click that button and then connect Portainer to the GitHub repository.
Copy and paste the contents of the full-stack docker-compose file into the web editor. Since our sample already defines the environment variables, we don’t need to add them. However, if you’re working with your own custom docker-compose file that requires you to add environment variables, click Add an environment variable (below the web editor) and then add the name and value (Figure 6).
Scroll to the bottom of the page and click Restricted. This is where we can now give our newly-created team access to the stack. From the Authorized teams drop-down (Figure 7), select the team we just created. If you want to also give authorization to individual users, you can do that from the Authorized users drop-down.
Once you’ve taken care of everything, the Deploy stack button should become available. Click that and the Portainer will begin the process of deployment. Depending on how complicated your stack is, the deployment can take some time.
When the deployment finishes, you can then click on the new stack to see all of the constituent parts running (Figure 8).
This is also where you can manage the stack (starting, stopping, killing, etc.). It’s also important to point out that since our sample was created outside of Portainer, we won’t have as much control over it. This illustrates the fact that you can use Portainer for every step of the full-stack deployment. You can create images and house them in the local registry, create volumes, and networks to apply to the stack, and more.
And that’s all there is to deploying a full-stack application using the Portainer web-based GUI. I highly recommend this platform for your container development, as it will make it far more efficient and collaborative.