Set up a Linux build environment
As an open source product, we encourage users to edit our code and submit patches to it. This article explains how to set up a local environment on Linux so you can build your own copy of Portainer and test your changes.
We tested these instructions on Ubuntu 18.04.2 LTS. For instructions that relate to other systems, see the linked documentation below.

Dependencies

  • Docker CE is the Docker application that runs on your machine to enable the use of Docker features. The latest version is not a requirement for this development stack, however we recommend staying up to date with the latest improvements and security fixes.
  • Yarn is a package manager for installing new software packages on your system, and is used to run the Portainer development environment.
  • Node.JS is a JavaScript package used when building applications that leverage networking, such as Portainer. Version 12 or later is required.
  • Golang is the open source language that we use to build the majority of Portainer software. Version 1.15 of Golang is required.
  • Wget is a package used to retrieve files using common internet protocols such as HTTP and FTP.

Part 1: Installing Docker

The following instructions were run on Ubuntu, for up-to-date instructions on this and other Linux distributions read the official Docker CE documentation.
You must configure the Docker repository before you install Docker.

Step 1: Configure the Docker repository

First, update your system's packages using this command:
1
sudo apt-get update
Copied!
Next, install the required packages to use repos over HTTPS:
1
sudo apt-get install \
2
apt-transport-https \
3
ca-certificates \
4
curl \
5
gnupg-agent \
6
software-properties-common
Copied!
Now install the official GPG key for Docker:
1
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Copied!
Use this fingerprint to confirm that you have the correct key:
9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
1
sudo apt-key fingerprint 0EBFCD88
Copied!
The correct output should be:
1
pub rsa4096 2017-02-22 [SCEA]
2
9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
3
uid [ unknown] Docker Release (CE deb) <[email protected]>
4
sub rsa4096 2017-02-22 [S]
Copied!
And finally, use the following command to set up the stable repository:
1
sudo add-apt-repository \
2
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
3
$(lsb_release -cs) \
4
stable"
Copied!

Step 2: Install Docker

We always recommend installing software using the most up-to-date instructions from the official vendor. This step is based on Docker's own installation instructions for Docker on Linux.
First, update your system's packages using this command:
1
sudo apt-get update
Copied!
Next, install Docker and its associated packages:
1
sudo apt-get install docker-ce docker-ce-cli containerd.io
Copied!
Finally, verify that Docker was correctly installed and is running on your system. This command should download a test image that you can run in a container, print an informational message for then exit out of.
1
sudo docker run hello-world
Copied!

Part 2: Installing Yarn

If you are running a different Linux distribution than Ubuntu, read Yarn's own installation instructions for Yarn on Linux.
If you have issues installing or using Yarn, read their official documentation.
Run this command in the terminal to configure the Yarn repository on your system:
1
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
2
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
Copied!
Update your system's packages and install Yarn using this command:
1
sudo apt-get update && sudo apt-get install yarn
Copied!
Finally, run this command in the terminal to confirm that the Yarn installation was a success:
1
yarn --version
Copied!
The current version of Yarn should print out in your terminal, indicating that that it installed successfully and is running on your system.

Part 3: Installing or updating Node.JS

This procedure makes use of NVM to install Node.JS (Node.JS version 12 or later is required). NVM allows multiple different versions of Node.JS to be installed on a system and provides an easy way to switch between them.
If you have issues installing or updating Node.JS, read NVM's documentation.
First, install or update to the latest version of Node.JS by running this command in the terminal:
1
nvm install node
Copied!
Finally, check if Node is installed on your system:
1
node --version
Copied!
The latest version of Node.JS should now print out.

Part 4: Installing Golang using a Linux tar file

Go version 1.15 must be installed. If you're upgrading from an older version, you must remove the existing version first before installing version 1.15. For the most up-to-date installation instructions, read Go's own documentation.
If you have issues installing or using Go, read the Getting help section in their official documentation.
First, download the appropriate version of Go for your system. Navigate to where it was downloaded then extract it to the /usr/local directory using this command:
1
sudo tar -C /usr/local -xzf go1.15.3.linux-amd64.tar.gz
Copied!
Next, add /usr/local/go/bin to the PATH environment variable inside your shell profile. Here's an example using bash:
1
echo "export PATH=$PATH:$HOME/go/bin:/usr/local/go/bin" >> ~/.bashrc
Copied!
You may need to log out and log back in for this to take effect.
And finally, follow the Test your installation section in Golang's official documentation to ensure that Go installed correctly.

Part 5: Installing Wget

If you have issues installing or using Wget, read their documentation.
To install Wget on Linux, simply run the apt-get install wget command in the terminal.
Last modified 2mo ago