[5 Mins Docker] Deploy Your Own Online Toolbox – IT-Tools – 51 Security

[5 Mins Docker] Deploy Your Own Online Toolbox – IT-Tools – 51 Security


IT-Tools is developed by Corentin Thomasset, who has included various practical tools in the GitHub repository, useful in different use cases like code conversion, OTP code generation, JWT parsing, SQL query building, password generators, and many more. Utilizing the wide variety of tools available in IT-Tools would drastically increase your workflow efficiency because it negates the usage of several online services.

In this article, I’ll provide a step-by-step guide on installing and deploying IT-Tools with Docker on your own machine.

 

IT-Tools

Github site: https://github.com/CorentinTh/it-tools

Author: Corentin Thomasset – https://github.com/CorentinTh

Demo site: https://it-tools.tech/

10 Categories , and 80+ Tools

Docker Playground

Lets start with Docker Playground to test it out

1 Log into https://labs.play-with-docker.com/

2 Create an instance then paste following docker run command in

COPY: ctrl + ins

PASTE: ctrl + shift + v

docker run -d --name it-tools --restart unless-stopped -p 8080:80 corentinth/it-tools:latest

3 Click port 8080 to open this web app page in a new tab

CodeSandbox – Docker

Plan: Free 

  • 400 VM credits started, Up to 40 hours worth of VM credits per month (10 credit / hour)
  • 5 sandboxes

Vercel Deployment

 Fork the project (https://github.com/CorentinTh/it-tools)  into your own Github repository.

Create a new project in your Vercel account.

Add your own domain from Vercel project settings page:

then add cname record into CloudFlare which I am using it to manage my dns records:

Self-hosted Docker Deployment

1 Docker Run command

docker run -d --name it-tools --restart unless-stopped -p 8080:80 corentinth/it-tools:latest

2 Docker run to Docker Compose

3 Docker Compose file

version: ‘3.9’

services:

    it-tools:

        image: ‘corentinth/it-tools:latest’

        ports:

            – ‘8080:80’

        restart: unless-stopped

        container_name: it-tools

4 Docker compose up -d

Use Your Own Domain

Cloudflare: add a dns A record to point to your NPM

Add a new site in NPM (Nginx Proxy Manager)

Self Hosted Docker Installation Pre-requirements

Free resources you might need to complete this docker project:

Pre-installed services:

  • Docker, 
    • apt update
    • apt install docker.io
    • apt install docker-compose
    • apt upgrade docker.io
    • mkdir /root/data/docker_data/<docker_name>
  • Docker-Compose (Using Ubuntu OS for the commands)
    • Docker-compose down
    • Optional command : use following command to backup your Docker data. You might need to change your folder name based on your docker configuraiton
      • cp -r /root/data/docker_data/<docker_name> /root/data/docker_data_backup/<docker_name>
    • docker-compose pull
    • docker-compose up -d
    • docker image prune
  • Portainer (Optional)
    • docker volume create portainer_data
    • docker run -d -p 9000:9000 –name portainer –restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
  • Install some applications: apt install wget curl sudo vim git (Optional)
  • aapanel with Nginx (Optional)
  • Nginx Proxy Manager (Optional)
  • Install screen (Optional)
    • Install screen (Depends on the Linux Distribution if it came pre installed or not) : yum install screen
    • Initiate a Screen : screen or  screen -S <screen name> <command to execute>
    • Detach from the screen : “CTRL+A,D” not “CTRL+A+D”
    • List all the screen currently working : screen -ls
    • Reattach to a screen : screen  -r  <session number> or screen -r <screen name>
    • Kill specific screen: screen -X -S <screen name> quit
    • Kill all screens : pkill screen

Monitoring Usage, especially for disk usage

Remove Docker and Related folders

  • docker stop <Docker Name> # stop the docker but not remove anything. 
  • docker rm -f <Docker Name>  # remove speficic container, but will not delete mapped volumes
  • rm -rf /root/data/docker_data/<Docker Mapped Volumns>  # remove all mapped volumes

Restrick Journal Log File Size:

  • journalctl –vacuum-size=100M
  • Limit it to 25M:

nano /etc/systemd/journald.conf
SystemMaxUse=25M
systemctl restart systemd-journald.service

or 

sudo bash -c 'echo "SystemMaxUse=100M" >> /etc/systemd/journald.conf'
sudo systemctl restart systemd-journald

Enable IPv6 and Limit Log File Size (Ubuntu)

Special command to cleans all logs and you don’t need to stop the containers.

  • sudo sh -c 'truncate -s 0 /var/lib/docker/containers/*/*-json.log'

Add customized self defined IPv6 address segment to enable container’s IPv6 fucntion. And limit log file’s size and numbers in case log file to fill all hard drive’s space. 

cat > /etc/docker/daemon.json << EOF
{
    "log-driver": "json-file",
    "log-opts": {
        "max-size": "20m",
        "max-file": "3"
    },
    "ipv6": true,
    "fixed-cidr-v6": "fd00:dead:beef:c0::/80",
    "eixperimental":true,
    "ip6tables":true
}
EOF

If there is any error, or IPv6 part might not work in the platform you might want to change it to list:

cat <<EOF > /etc/docker/daemon.json
{
  "live-restore": true,
  "storage-driver": "overlay2",
  "log-opts": {
    "max-size": "10m"
  }
}
EOF
Restart Docker service:

systemctl restart docker

Limit number of log files:

cat /etc/logrotate.d/rsyslog
/var/log/syslog
/var/log/mail.info
/var/log/mail.warn
/var/log/mail.err
/var/log/mail.log
/var/log/daemon.log
/var/log/kern.log
/var/log/auth.log
/var/log/user.log
/var/log/lpr.log
/var/log/cron.log
/var/log/debug
/var/log/messages
{
    rotate 4
    weekly
    missingok
    notifempty
    compress
    delaycompress
    sharedscripts
    postrotate
        /usr/lib/rsyslog/rsyslog-rotate
    endscript
}

You can change 4 to some other value, such as 1, so that only one file is stored.

Videos

 

Post Comment