- Install Prerequisites
- Setup Docker Swarm
- Setup Traefik
- Setup Portainer
- Setup MariaDB
- Setup Swarm CRON
- Setup ERPNext
These steps are required for production server. For dind/local setup copy dind-devcontainer
to .devcontainer
and reopen in devcontainer.
Use files from compose
directory.
Setup assumes you are using Debian based Linux distribution.
Update packages
apt-get update && apt-get dist-upgrade -y
Setup unattended upgrades
dpkg-reconfigure --priority=medium unattended-upgrades
Add non-root sudo user
adduser -D ubuntu
usermod -aG sudo ubuntu
curl -fsSL https://get.docker.com | bash
usermod -aG docker ubuntu
su - ubuntu
Clone this repo
git clone https://github.com/castlecraft/custom_containers
cd custom_containers
Note: traefik and portainer yamls specified in the further commands are in compose
directory.
Initialize swarm
docker swarm init --advertise-addr=X.X.X.X
Note: Make sure the advertise-address does not change if you wish to add multiple nodes to this manager.
Comprehensive guide available at dockerswarm.rocks
More on Traefik
Label the master node to install Traefik
docker node update --label-add traefik-public.traefik-public-certificates=true $(docker info -f '{{.Swarm.NodeID}}')
Set email and traefik domain
export [email protected]
export TRAEFIK_DOMAIN=traefik.example.com
# or for dind
export TRAEFIK_DOMAIN=traefik.localhost
Set HASHED_PASSWORD
export HASHED_PASSWORD=$(openssl passwd -apr1)
Password: $ enter your password here
Verifying - Password: $ re enter your password here
Install Traefik in production
docker stack deploy -c compose/traefik-host.yml traefik
Install Traefik in dind
source /workspace/dind-devcontainer/setup-docker-env.sh
docker stack deploy -c /workspace/compose/traefik-dind.yml traefik
More on portainer
Label the master node to install portainer
docker node update --label-add portainer.portainer-data=true $(docker info -f '{{.Swarm.NodeID}}')
Install Portainer in production
# Set domain
export PORTAINER_DOMAIN=portainer.example.com
# Install
docker stack deploy -c compose/portainer.yml portainer
Install Portainer in dind
# Set domain
export PORTAINER_DOMAIN=portainer.localhost
# Install
docker stack deploy -c /workspace/compose/portainer-dind.yml portainer
Initialize portainer
export PORTAINER_PASSWORD=supersecretpassword
http POST https://docker/api/users/admin/init "Host: portainer.localhost" Username="admin" Password="${PORTAINER_PASSWORD}" --follow --verify=no
Get bearer token
export TOKEN=$(http POST https://docker/api/auth "Host: portainer.localhost" Username=admin Password=${PORTAINER_PASSWORD} --follow --verify=no | jq -r .jwt)
Add endpoint
source /workspace/dind-devcontainer/setup-docker-env.sh
http POST \
https://docker/api/endpoints \
"Authorization:Bearer $TOKEN" \
"Host:portainer.localhost" \
Name=dind EndpointCreationType=1 URL=tcp://$DOCKER_API \
--follow \
--form \
--verify=no
- Go to Stacks > Add and create stack called
mariadb
. - Set
DB_PASSWORD
environment variable to set mariadb root password. Defaults toadmin
. - Use
compose/mariadb.yml
to create the stack.
In case of docker setup there is not CRON scheduler running. It is needed to take periodic backups.
- Go to Stacks > Add and create stack called
swarm-cron
. - Use
compose/swarm-cron.yml
to create the stack. - Change the
TZ
environment variable as per your timezone.
compose/erpnext.yml
: Use to create theerpnext
stack. Set variable names mentioned in the YAML comments.compose/configure-erpnext.yml
: Use to setupsites/common_site_config.json
. SetVERSION
and optionallyBENCH_NAME
environment variables.compose/create-site.yml
: Use to create a site. SetVERSION
and optionallyBENCH_NAME
environment variables. Change the command for site name, apps to be installed, admin password and db root password.