docker
Posted: 14 May 2024, 19:18pm - Tuesday

 I have been using docker lately. I have these legacy personal projects that I can't just abandon them. Still display in my portfolio. :) Then my new projects are now using Symfony 6.4 with MySQL 8.0. It is the time that I need both MySQL v5.7 and v8.x to run side-by-side in my server. Here's my docker-compose.yaml

version: '3.1'

services:
   mysql8:
      container_name: docker_mysql8
      image: mysql:8.0
      ports:
        - 3313:3306
      restart: always
      environment:
        MYSQL_USER: user
        MYSQL_PASSWORD: xxx
        MYSQL_ROOT_PASSWORD: xxx
        MYSQL_ROOT_HOST: "%"
        MYSQL_PORT: 3306
      volumes:
        - /var/lib/mysqld8:/var/lib/mysql
      healthcheck:
        test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
        timeout: 20s
        retries: 10
      networks:
        - default
   mysql5_7:
      container_name: docker_mysql5_7
      image: mysql:5.7
      ports:
        - 3312:3306
      restart: always
      environment:
        MYSQL_USER: user
        MYSQL_PASSWORD: xxxx
        MYSQL_ROOT_PASSWORD: xxxx
        MYSQL_ROOT_HOST: "%"
        MYSQL_PORT: 3306
      volumes:
        - /var/lib/mysqld57:/var/lib/mysql
      healthcheck:
        test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
        timeout: 20s
        retries: 10
      networks:
        - default

 

then save it let's say at "/srv/mysql/docker-compose.yaml" and to initialise, run "docker-compose up -d"

one thing to remember though, if you want to make some changes. Never cast the command: "docker-composer down" because this will delete the data you got in the container unless you created backups.

instead, just do "docker-compose stop" to stop the container and "docker-compose start" when you want to get the container running again.

if errors encounter, simply just restart docker then cast "systemctl restart docker" then go to "/srv/mysql" and run "docker-compose up -d"

enlarge
GPG error: The following signatures were invalid
Posted: 30 Jun 2021, 20:42pm - Wednesday
W: GPG error: https://dl.yarnpkg.com/debian stable InRelease: The following signatures were invalid: EXPKEYSIG 23E7166788B63E1E Yarn Packaging <yarn@dan.cx>
E: The repository 'https://dl.yarnpkg.com/debian stable InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

Solution:

sudo apt-key adv --keyserver hkps://keyserver.ubuntu.com --refresh-keys
enlarge
bash: load db with progress
Posted: 24 Sep 2020, 4:01am - Thursday

Just want to share this and my reminder how to create the script.

#!/bin/bash

NOW=$(date -d '-1 day' '+%Y-%m-%d')

COUNCIL=$1

gzip -dv db_${NOW}/${COUNCIL}_checklists.mysql.dmp.gz
gzip -dv db_${NOW}/${COUNCIL}_obca.mysql.dmp.gz
gzip -dv db_${NOW}/${COUNCIL}_fileman.mysql.dmp.gz
gzip -dv db_${NOW}/${COUNCIL}_logging.mysql.dmp.gz

mysql -h 127.0.0.1 -u root -psecret -e "CREATE DATABASE IF NOT EXISTS ${COUNCIL}_checklists"
mysql -h 127.0.0.1 -u root -psecret -e "CREATE DATABASE IF NOT EXISTS ${COUNCIL}_obca"
mysql -h 127.0.0.1 -u root -psecret -e "CREATE DATABASE IF NOT EXISTS ${COUNCIL}_logging"
mysql -h 127.0.0.1 -u root -psecret -e "CREATE DATABASE IF NOT EXISTS ${COUNCIL}_fileman"

#mysql ${COUNCIL}_checklists -h 127.0.0.1 -u root -psecret --force < db_${NOW}/${COUNCIL}_checklists.mysql.dmp
#mysql ${COUNCIL}_obca -h 127.0.0.1 -u root -psecret < db_${NOW}/${COUNCIL}_obca.mysql.dmp
#mysql ${COUNCIL}_fileman -h 127.0.0.1 -u root -psecret < db_${NOW}/${COUNCIL}_fileman.mysql.dmp
#mysql ${COUNCIL}_logging -h 127.0.0.1 -u root -psecret < db_${NOW}/${COUNCIL}_logging.mysql.dmp

pv db_${NOW}/${COUNCIL}_checklists.mysql.dmp | mysql ${COUNCIL}_checklists -h 127.0.0.1 -u root -psecret --force
pv db_${NOW}/${COUNCIL}_obca.mysql.dmp | mysql ${COUNCIL}_obca -h 127.0.0.1 -u root -psecret --force
pv db_${NOW}/${COUNCIL}_logging.mysql.dmp | mysql ${COUNCIL}_logging -h 127.0.0.1 -u root -psecret --force
pv db_${NOW}/${COUNCIL}_fileman.mysql.dmp | mysql ${COUNCIL}_fileman -h 127.0.0.1 -u root -psecret --force

gzip -9v db_${NOW}/${COUNCIL}_checklists.mysql.dmp
gzip -9v db_${NOW}/${COUNCIL}_obca.mysql.dmp
gzip -9v db_${NOW}/${COUNCIL}_fileman.mysql.dmp
gzip -9v db_${NOW}/${COUNCIL}_logging.mysql.dmp

echo "Import completed!"

Sample output below:

screenshot of the script in action...

That's it! Cheers!

enlarge

 

This quality property has been designed and built to make living and outdoor entertaining a breeze.

 

The heart of the home is the beautiful kitchen with a stone bench countertop, quality appliances, walk-in pantry, and breakfast bar - an ideal spot for quick easy family meals. The kitchen overlooks the relaxed family dining living with seamless flow to the expansive covered entertaining patio, which is enjoyed all year round - you will be impressed! The separate lounge allows for you to pop away for a quiet moment.

 

You will enjoy the roomy master bedroom with an en suite, walk-in wardrobe, and access outdoors to the patio. The other three bedrooms are good sizes with the third located near the front entrance and family living, perfect for those who work from home and those who wish the kids to be nearby while working on their homework.

 

A large double garage with internal access is a must and don't we all love a separate laundry room. Gardens are low maintenance and with some raised garden beds.

 

The location is superb, close to the Summerhill shopping centre and zoned for quality schools. This quality brick home was built in 2019 and is in "as new" condition.

 

Please ring us today to make a time to view or come along to one of our Open Homes, we would love to show you through. Call Lyndsey - 0274462886 or Stu - 0274441594

 

For further information on this property please visit:
https://www.13mediterraneangrove.co.nz or https://rwpalmerstonnorth.co.nz/PNO30173

STATUS: SOLD

enlarge
Quirks on jQuery plugin "lc_switch"
Posted: 12 May 2021, 21:57pm - Wednesday

We've been using lc_switch for our new UI revamp and found some quirks. Here they are:

When binding lc_switch jQuery plugin, do not do these following:

QUIRK 1

WRONG

<label class="ocl-switch-label" for="app_confidential">
    <input class="ocl-switch" type="checkbox" id="app_confidential" name="app_confidential" /> Is the project confidential?
</label>

CORRECT

<label class="ocl-switch-label" for="app_confidential">
    <input class="ocl-switch" type="checkbox" id="app_confidential_answer" name="app_confidential" /> Is the project confidential?
</label>

EXPLANATION:

You should not name the element id and name the same

QUIRK 2

WRONG

<label class="ocl-switch-label" for="app_confidential_answer">
    <input class="ocl-switch" type="checkbox" id="app_confidential_answer" name="app_confidential" /> Is the project confidential?
</label>

CORRECT

<label class="ocl-switch-label" for="app_confidential">
    <input class="ocl-switch" type="checkbox" id="app_confidential_answer" name="app_confidential" /> Is the project confidential?
</label>

EXPLANATION:

You should not address label tag for="" attribute to an element's id, instead address to element's name

enlarge
Securing Mail Server SSL/TLS
Posted: 8 Jul 2021, 23:28pm - Thursday

I have been auditing our servers security. I was trying to resolved some issues detected by tenable.io, one of the issue raised was the SWEET32. There are few, by I am not disclosing that here. :) To resolve all vulnerabilities, these are my new settings in my postfix (main.cf) :

smtpd_tls_mandatory_exclude_ciphers = aNULL, eNULL, EXPORT, DES, RC4, MD5, PSK, aECDH, EDH-DSS-DES-CBC3-SHA, EDH-RSA-DES-CDC3-SHA, KRB5-DE5, CBC3-SHA, EXP, MEDIUM, ADH, AECDH, DSS, ECDSA, CAMELLIA128, 3DES, CAMELLIA256, RSA+AES
smtpd_tls_mandatory_protocols = !SSLv2 !SLv3 !TLSv1
smtpd_tls_protocols = !SSLv2 !SSLv3 !TLSv1

then restart postfix:

postfix stop; postfix start

that's it. it resolved my issues.

enlarge
Delete all git local branches
Posted: 3 Feb 2021, 2:59am - Wednesday

I was wondering how to delete all local git branch in Windows. But I didn't bother as I realized I got Cygwin anyway so I just took the Linux one... :) So I write a bash script named "clean_git.sh" with this contents:

#!/bin/bash
git checkout master
# git pull - optional
git status
git branch | grep -v "master" | xargs git branch -D

Cheers!

enlarge