Thursday, 11 April 2024

Install Mysql for Laragon

* Check system type window

- Under Control Panel, click System => check system type

* Download and install softwares

- Mysql
+ mysql-8.0=https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.30-winx64.zip
+ mysql-5.7=https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.39-winx64.zip
+ mysql-5.6=https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.51-winx64.zip
Then extract and move mysql folder to C:\laragon\bin\mysql

- Microsoft Visual C++
+ Version:10.0: https://www.microsoft.com/en-us/download/details.aspx?id=26999
=> Supported Operating Systems Windows XP, Windows Server 2003 R2 x64 editions, Windows Vista Service Pack 2, Windows Server 2003 R2 (32-Bit x86), Windows Server 2008 R2, Windows 7
/ Note: My PC window10, 64-bit operating system, x64-based processor, install vcredist_x64 Version:10.0 for mysql-5.6 run successful, but install Version:2012.4 then error, can not find vcredist_x64.

+ Version:2012.4: https://www.microsoft.com/en-us/download/details.aspx?id=30679
=> Supported Operating Systems Windows 7 Service Pack 1, Windows 8, Windows 8.1, Windows Server 2003, Windows Server 2008 R2 SP1, Windows Server 2008 Service Pack 2, Windows Server 2012, Windows Vista Service Pack 2, Windows XP

* Delete Mysql folder

- delete folder C:\laragon\data\mysql when you install mysql-5.6 or mysql-5.7 (because mysql-5.6 and mysql-5.7 when install laragon create same folder name in C:\laragon\data\mysql)

user: root

pass: ''

Thank you

Thursday, 4 April 2024

Google Cloud Platform (GCP) tutorial from basic to advanced

1. What to use GCP for?

GCP is collection of cloud services provides by Google. 

2. How to use GCP?

- Create a Google Cloud Platform Account
- Navigate the GCP Console
- Create a GCP Project
- Enable Billing and APIs
- Explore GCP Services
- Create and Manage Resources
- Utilize Documentation and Tutorials
- Use Command Line Tools and SDKs
- Consider Security and Compliance
- Monitor and Optimize Usage

3. What does Permanent Agent server include? 

* Compute
- Computed engine (scalable & fast virtual machines)
- Kubernetes engine (run containerized applications)
- App engine (to support deploy web applications in many environment)
- Cloud function (light weight application)

* Storage
- Cloud Storage (storage anythings)
- Big Table (no SQL)
- Cloud SQL (relation database)
- Cloud Spanner (is Cloud SQL + with scale)
- Cloud data storage (is Big Table + with scale)

* Big Data
- Big Query (data warehouse)
- Pub/Sub (stream data)
- Data Flow (ETL (extract-transform-load))
- Data Catalog (Meta data management)

* AI
- Natural language API (understand text segment analysis)
- Vision API (read images)
- Speech API (speech to text)
- Translate API (translate languages)

* Others
- Billing
- IAM & Admin
- VPC network
- Security
- Third parties

--------------------------
Detailed instructions

References:

Thank you

 

Wednesday, 3 April 2024

Pipelines & Jenkinsfile in Jenkins

1. What to use Pipelines & Jenkinsfile for?

-  A Pipeline is a series of automated executed job steps, is used to automate CICD (build, test, deploy, report)

- A Jenkinsfile is a text file, is used to define a Jenkins Pipeline.

2. How to use Pipelines & Jenkinsfile?

- Create a Pipeline is create a job in Jenkins >> see more: Create a Pipeline

- Jenkinsfile syntax:

pipeline {
    agent none
options {
timeout(time: 1, unit: 'HOURS') // Sets a timeout limit for the pipeline
retries(2) // Retries the pipeline 2 times in case of failure
buildDiscarder(logRotator(numToKeepStr: '5')) // Keeps the logs of the last 5 builds
} 
  environment {
MY_VARIABLE = "someValue" // Define a simple environment variable
PASSWORD = credentials('my-credential-id') // Safely inject a password from Jenkins credentials
}
    stages {
stage('Advanced Script') {
steps {
script {
// Your Groovy code here
                   echo "Environment variable is $MY_VARIABLE"
}
}
} 
        stage('Build') {
            agent any 
            steps {
                // Steps to build the application
                echo 'This is Build stage.'
            }
        }
        stage('Test') {
            agent { 
                label 'linux-server-test' 
            } 
            steps {
                // Steps to Test the application
            }
            post { 
                always { 
                    echo 'Test on linux-server-test finished.'
                } 
            }
        }
        stage('Deploy') {
            agent { 
                label 'linux-server-deploy' 
            } 
            steps {
                // Steps to Deploy the application
            }
            post { 
                always { 
                    echo 'Deploy on linux-server-deploy finished.'
                } 
            }
        }
    }
    post {
        always {
            echo 'This message will always be printed.'
        }
        success {
            echo 'This message will only be printed if the pipeline succeeds.'
        }
        failure {
            echo 'This message will only be printed if the pipeline fails.'
        }
    }
}  

Explain:
+ pipeline: define main pipeline
+ agent: specifies agent stages will be executed
+ option: to change default behavior of Jenkins pipeline
+ environment: define variables for using by all stages, steps, script in pipeline.
+ stages: define stages of pipeline
+ stage: define a specific stage
+ steps: contents steps to perform work in stage
+ script: to using Groovy code in pipeline
+ post: define actions or steps that are executed at the end of pipeline
+ always: steps are executed after every run of pipeline
+ success: steps are executed only if pipeline completes success
+ failure: steps are executed only if pipeline fails 

Reference
- https://www.jenkins.io/doc/book/pipeline/jenkinsfile/

Thank you.

Tuesday, 2 April 2024

Permanent Agent server using VPS in Jenkins

1. What to use Permanent Agent server for?

- Permanent Agent is a Jenkins agent for deploy (CD) app.

2. How to use Permanent Agent server?

- Install Java in server agent: install java version, setup JAVA_HOME path the same with jenkin master server, example jdk11.0.11, JAVA_HOME=/usr/lib/jvm/..

- Create agent: Mange Jenkins > Manage node and cloud > New node > Node name: Agent1 > Type: checked Permanent Agent > Number of executors: 2 > Remote root directory: /home/jenkins/Agent1 > Labels: Agent1 Linux > Usage: Use this node as much as possible > Launch method: Launch agents via SSH > Disable WorkDir: not checked > Custom WorkDir path: /home/jenkins/ Availability: Keep this agent online as much as possible > Save
+ Number of executors: with Executor is represent a separate process capable of executing a job, ex = 2 => can run 2 jobs same time.
+ Launch agent has two ways:
/ By connecting it to master (also call controller): Agent connect to Jenkins, by run jar file download from jenkins (using when don't want open ssh).
/ Via SSH: Jenkins connect to Agent, by using ssh to agent (using when has ssh on agent): Host: Agent1 > Credentials: (Select existed) || Add new > Domain: Global credentials (unrestricted) > Kind: SSH Username with private key || (Username & Password) > ID: CredentailLinuxAgent > return to select existed Credential already create > Host Key Verification Strategy: None verify verification Strategy. > Click Advanced > Port: 22 (your ssh agent port) 
+ Remote root directory: the path for jenkin create, manage working file...
+ Host key verification Strategy:
/ None verify verification Strategy (just connect, ignore everything)
/ Know hosts file Verification Strategy (need config ssh agent host in known host verification on jenkins master host: go to host master > cd /var/lib/jenkins/ (|| jenkins path docker if you use docker run jenkin: ../laradock/jenkins/jenkins_home) > mkdir -p /var/jenins/.ssh > ssh-keyscan -H Agent1 >> var/lib/jenkins/.ssh/know_hosts (collect ssh key from Agent1 server, after write them to know_hosts file > chow -R jenkins:jenkins /var/lib/jenkins/.ssh).

- Run the permanent Agents:
+ Configure global security: Agent: TCP port for inbound agents: Fixed: 50000
+ Manage nodes and clouds > Click Open the agent > run from agent command line in /home/jenkins (to install java, javac)

- Using the Permanent Agent: Select job/ Configure/ checked Restrict where this project can be run?/ Label Expression: Agent1/ Save/ Build job again/

Reference: Setting up Permanent Agents

3. What does Permanent Agent server include? 

--------------------------
Detailed instructions

References:
- https://www.youtube.com/watch?v=99DddJiH7lM

Thank you.

Docker Pipeline Plugin in Jenkins

1. What to use Docker Pipeline Plugin for?
- To use Docker as a Agent

2. How to use Docker Pipeline Plugin?

- Install Docker pipeline plugin: Manage Jenkins/ manage Plugins/ search Docker Pipeline/ Download now and restart/ Restart

- Using this git repository

- Create job pipeline: New item/ name: Docker/ Select Pipeline/ OK/ select Pipeline script from SCM/ SCM: Git/ Reposiotry: url git repository/ Credentials none (because this repository is public) / branch: main/ script path: Jenkinsfile-1 | Jenkinsfile-2 | Jenkinsfile-3 / Save / Build -> show Result

3. What does Docker Pipeline Plugin include? 

-------------------------
Detailed instructions

Thank you.

Monday, 1 April 2024

Setup Xdebug for Laragon, VsCode

References

Page guide install xdebug

https://xdebug.org/docs/install

https://xdebug.org/wizard

Install PHP Debug plugin for vsCode

https://pen-y-fan.github.io/2021/08/03/How-to-Set-up-VS-Code-to-use-PHP-with-Xdebug-3-on-Windows/

file php.ini

[xdebug]
zend_extension = xdebug
xdebug.mode = coverage,debug,develop
xdebug.client_port = 9003
xdebug.start_with_request = 1
xdebug.idekey = VSCODE  

file .vscode\launch.json

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 0,
"runtimeArgs": [
"-dxdebug.start_with_request=yes"
],
"env": {
"XDEBUG_MODE": "debug,develop",
"XDEBUG_CONFIG": "client_port=${port}"
}
},
{
"name": "Launch Built-in web server",
"type": "php",
"request": "launch",
"runtimeArgs": [
"-dxdebug.mode=debug",
"-dxdebug.start_with_request=yes",
"-S",
"localhost:0"
],
"program": "",
"cwd": "${workspaceRoot}",
"port": 9003,
"serverReadyAction": {
"pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
"uriFormat": "http://localhost:%s",
"action": "openExternally"
}
}
]
} 

* Note: When install PHP Debug need follow step:

- Enable Xdebug in php, then restart server apache/nginx

- Click Run/ Add Configuration

Thank you

Publish npm package

  Để publish   pav-kit  lên NPM, bạn hãy làm theo các bước dưới đây. Tôi đã tạo thêm file  index.js  để đảm bảo gói tin hợp lệ. Bước 1: Tạo ...