Skip to content

Instantly share code, notes, and snippets.

@islander
Created July 15, 2019 01:33
Show Gist options
  • Save islander/44f13a5173a55c06bd7d9bc5f7a1126f to your computer and use it in GitHub Desktop.
Save islander/44f13a5173a55c06bd7d9bc5f7a1126f to your computer and use it in GitHub Desktop.
Deploy Portainer without docker

Deploy Portainer without docker

Install

Run install-portainer.sh. SystemD required.

Nginx reverse proxy

Add upstream and locations to your config.

# cat /etc/nginx/sites-enabled/default
upstream portainer {
    server 127.0.0.1:9000;
}

server {
    server_name _;
    listen 80;

    location /portainer/ {
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_pass http://portainer/;
    }
    location /portainer/api/websocket/ {
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_http_version 1.1;
        proxy_pass http://portainer/api/websocket/;
    }
}
#!/bin/bash
# deploy standalone Portainer (without docker)
VERSION="1.21.0"
ARCH="amd64"
CHECKSUM_URL="https://github.com/portainer/portainer/releases/download/$VERSION/portainer-$VERSION-linux-$ARCH-checksum.txt"
ARCHIVE_URL="https://github.com/portainer/portainer/releases/download/$VERSION/portainer-$VERSION-linux-$ARCH.tar.gz"
#####################
# Yes/No function #
#####################
confirm()
{
read -n 1 -r -p "${1}? [y/N] "
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo ""
return 0;
else
echo ""
return 1;
fi
}
cd /usr/src
# download
[ -s portainer-$VERSION-linux-$ARCH-checksum.txt ] || wget "$CHECKSUM_URL"
[ -s portainer-$VERSION-linux-$ARCH.tar.gz ] || wget "$ARCHIVE_URL"
# test checksum
if sha256sum -c --quiet --status "portainer-$VERSION-linux-$ARCH-checksum.txt"; then
[ -d portainer ] || tar -zxvf "portainer-$VERSION-linux-$ARCH.tar.gz"
fi
# prepare directories
mkdir -p /usr/local/share/portainer
mkdir -p /var/lib/portainer
mkdir -p /etc/portainer
# install files
cp portainer/public /usr/local/share/portainer
cp portainer/portainer /usr/local/bin
cp portainer/templates.json /etc/portainer
# prepare systemd service
cat <<'EOF' > /etc/systemd/system/portainer.service
[Unit]
Description=Portainer.io management ui
After=docker.service
Wants=docker.service
[Service]
Type=simple
Restart=always
RestartSec=3
Environment=ASSETS=/usr/local/share/portainer
Environment=DBFILES=/var/lib/portainer
Environment=TPLFILE=/etc/portainer/templates.json
ExecStart=/usr/local/bin/portainer --bind="127.0.0.1:9000" -a ${ASSETS} -d ${DBFILES} --template-file="${TPLFILE}"
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
confirm "start portainer" && (echo "starting."; echo ""; systemctl start portainer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment