2023년 3월 13일 월요일

[Docker] docker build RUN apk update Error

Step 3/7 : RUN apk update

 ---> Running in 2fdba320b542

fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz

fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz

ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.9/main: temporary error (try again later)

WARNING: Ignoring APKINDEX.b89edf6e.tar.gz: No such file or directory

ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.9/community: temporary error (try again later)

WARNING: Ignoring APKINDEX.737f7e01.tar.gz: No such file or directory



$ docker build --tag shlee/springboot-cicd:latest --no-cache --network=host .

 --> Add "--network=host" .. 

2023년 3월 10일 금요일

Nexus Installation on Ubuntu

$ mkdir nexus

$ wget https://download.sonatype.com/nexus/3/nexus-3.39.0-01-unix.tar.gz

$ sudo apt-get update

$ sudo apt install openjdk-8-jdk-headless

$ cd nexus/bin


- install & startup : nexus run

- startup : nexus start

- stop : nexus stop


SonarQube Installation ( on Ubuntu )

 $ sudo apt update




$ sudo apt -y install apt-transport-https ca-certificates curl gnupg-agent software-properties-common


$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -






$ wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-9.8.0.63668.zip


$ unzip sonarqube-9.8.0.63668.zip


$ sudo groupadd sonar


$ sudo useradd -c "SonarQube - User" -d /home/shlee/sonarqube/ -g sonar sonar


# $ sudo chown -R sonar:sonar /home/shlee/sonarqube/


$ sudo chown -R shlee:shlee /home/shlee/sonarqube/




$ /home/shlee/sonarqube/bin/linux-x86-64/sonar.sh start


$ /home/shlee/sonarqube/bin/linux-x86-64/sonar.sh stop




$ curl localhost:9000 [admin/admin and change password]




[SonarQube Setup in gitlab / SonarQube]


1) create gitlab Impersonation Token in Gitlab


2) create gitlab project and insert gitlab Token in sonarqube 


3) create credential for "admin" account in sonarqube 


   and copy credential, paste to jenkins new credentials






[SonarQube Setup In jenkins]


Install GitLab plugin for Jenkins - version 1.5.13 or later


Install SonarQube Scanner plugin for Jenkins - version 2.11 or later




setting for integrating cicd


setting for sonarqube server 




[Jenkinsfile]


  withSonarQubeEnv('sonarqube_rookie01') {


                sh "mvn clean verify sonar:sonar -Dsonar.projectKey=springboot_springboot-cicd_AYUplgxydso4nsDrpk6X"


              }




sonarqube_rookie01 <- ID for sonarQube Server Setting


springboot_springboot-cicd_AYUplgxydso4nsDrpk6X <-- project key in sonarqube


-----




(1) Docker Push in Jenkinsfile


 docker.withRegistry('<Docker Registry URL>', '<Credential defined in Jenkins Credentials>') {


     dockerImage.push('<Tag>')


 }




ex>


 docker.withRegistry('http://localhost:7890/repository/docker-local-registry/', 'docker_credential') {


      dockerImage.push('latest')


 }




(2) Integrate Sonar with Jenkins


 withSonarQubeEnv('<Name of Jenkins SonarQube Server Settings>') {


      sh "mvn clean verify <Goal for SonarQube (default :  'sonar:sonar' )> -Dsonar.projectKey=<ProjectKey generated by SonarQube Server>"


 }

Prometheus & Grafana Installation (on Ubuntu)

 [Prometheus]


1) download prometheus

$ wget http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz

압축 해제.. & prometheus.yml 편집

scrape_configs:

  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.

  - job_name: "prometheus"


    # metrics_path defaults to '/metrics'

    # scheme defaults to 'http'.

    static_configs:

      - targets: ["localhost:9091"]

      - 

  - job_name: "springboot"

    scrape_interval: 15s

    metrics_path: "/actuator/prometheus"

    static_configs:

      - targets: ["rookie01.local:8080"]

      - 

2) startup

$ ./prometheus --config.file=prometheus.yml  --web.listen-address="0.0.0.0:9091" --web.enable-lifecycle 2>&1 | tee -a ./startup.log &



3) shutdown

$ curl -X POST localhost:9091/-/quit   ( or kill )


4) brower 접속

http://localhost:9091

http://localhost:9091/metrics



[Grafana]

1) download installation file

$ wget wget https://dl.grafana.com/enterprise/release/grafana-enterprise-9.3.6.linux-amd64.tar.gz


2) startup

$ ./bin/grafana-server web


3) browser 접속

http://localhost:3000  ( admin / admin ; pwd 변경 : lsh~)


4) springboot 용 pannel 샘플 다운로드 / Import

 download from : https://grafana.com/grafana/dashboards/12900-springboot-apm-dashboard/