The Things Stack for LoRaWAN | Installation | Docker

 

The Things Stack Installation


# Rererence
# https://www.thethingsindustries.com/docs/the-things-stack/host/docker/
# Create a new directory and navigate into it
mkdir ttn_stack
cd ttn_stack
# Install Docker
# Update package information and install necessary packages
sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common
# Download and add Docker's official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# Add Docker repository to package sources
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
# Install Docker packages
sudo apt-get install docker-ce docker-ce-cli containerd.io
# Check Docker service status
sudo systemctl status docker
# Add the current user to the 'docker' group for non-root Docker usage
sudo usermod -aG docker ${USER}
# Refresh user's groups
su - ${USER}
# Verify Docker installation by listing containers
docker ps -a
# Install Docker Compose
sudo apt-get install docker-compose-plugin
# Check Docker Compose version
docker compose version
# Enable Docker and containerd services to start on boot
sudo systemctl enable docker.service
sudo systemctl enable containerd.service
# Get Docker Compose configuration file ()
wget https://www.thethingsindustries.com/docs/the-things-stack/host/docker/configuration/docker-compose-open-source.yml
# rename file
mv docker-compose-open-source.yml docker-compose.yml
# Create directories for configuration files
mkdir config
mkdir config/stack
# Get a sample configuration file for the TTN Stack in Docker
wget https://www.thethingsindustries.com/docs/the-things-stack/host/docker/configuration/ttn-lw-stack-docker-open-source.yml
# rename file
mv ttn-lw-stack-docker-open-source.yml ttn-lw-stack-docker.yml
# NOTE : Make all the required modifications in the docker-compose.yml and ttn-lw-stack-docker.yml files.
# https://www.thethingsindustries.com/docs/the-things-stack/host/docker/configuration/
# https://www.thethingsindustries.com/docs/the-things-stack/host/docker/certificates/
# Create a new directory named "acme" in the current location
mkdir ./acme
# Change the ownership of the "acme" directory to the user and group with ID 886
# This is useful for managing permissions and access to the directory
sudo chown 886:886 ./acme
# Allow incoming HTTP traffic (port 80)
sudo ufw allow 80
# Allow incoming HTTPS traffic (port 443)
sudo ufw allow 443
# Allow incoming SSH traffic (port 22)
sudo ufw allow 22
# Allow incoming traffic on various ports for TTN Stack
sudo ufw allow 1881
sudo ufw allow 1882
sudo ufw allow 1883
sudo ufw allow 1884
sudo ufw allow 1885
sudo ufw allow 1886
sudo ufw allow 1887
sudo ufw allow 1888
# Allow incoming traffic on various ports
sudo ufw allow 8881
sudo ufw allow 8882
sudo ufw allow 8883
sudo ufw allow 8884
sudo ufw allow 8885
sudo ufw allow 8886
sudo ufw allow 8887
sudo ufw allow 8888
# Allow incoming UDP traffic on port 1700 (for TTN)
sudo ufw allow 1700/udp
# Display the status of the UFW rules
sudo ufw status
# Enable the UFW firewall
sudo ufw enable
# Pulling the Docker images
docker-compose pull
# Initialize the database of the Identity Server
docker-compose run --rm stack is-db migrate
# Create admin user
docker-compose run --rm stack is-db create-admin-user --id admin_user_name --email your_email@gmail.com
# Create an OAuth client for the console
# replace with your SERVER_ADDRESS and Console CLIENT_SECRET
SERVER_ADDRESS=https://example.com
ID=console
NAME=Console
CLIENT_SECRET=example_secret
REDIRECT_URI=${SERVER_ADDRESS}/console/oauth/callback
REDIRECT_PATH=/console/oauth/callback
LOGOUT_REDIRECT_URI=${SERVER_ADDRESS}/console
LOGOUT_REDIRECT_PATH=/console
docker-compose run --rm stack is-db create-oauth-client \
--id ${ID} \
--name "${NAME}" \
--owner admin \
--secret "${CLIENT_SECRET}" \
--redirect-uri "${REDIRECT_URI}" \
--redirect-uri "${REDIRECT_PATH}" \
--logout-redirect-uri "${LOGOUT_REDIRECT_URI}" \
--logout-redirect-uri "${LOGOUT_REDIRECT_PATH}"
# Start The Things Stack with
docker-compose up -d
# To access stack shell
#docker exec -it ttn_stack_stack_1 /bin/sh
# To change logo
# Copy the file "account.svg" from the local machine to a specific location within the Docker container named "ttn_stack_stack_1"
# This command helps transfer files between the local filesystem and a running Docker container.
docker cp account.svg ttn_stack_stack_1:/srv/ttn-lorawan/public/account.svg
docker cp account.svg ttn_stack_stack_1:/srv/ttn-lorawan/public/account.svg


Comments

Popular Posts