Showing posts with label Nexus. Show all posts
Showing posts with label Nexus. Show all posts

Sunday, October 8, 2023

Install JFrog Artifactory on Linux instance | Setup JFrog Artifactory on Ubuntu | Install JFrog Artifactory 7.X on Ubuntu 22.0.4

Artifactory is one of the popular binary repository managers. It is Java based open source tool, used for storing build artifacts and docker images.

Some of the key features of Artifactory:
  • Supports 27 different package types including helm charts, docker images regardless of tech stack.
  • A single source of truth for all your binaries
  • Integration with all CICD tools
  • role based authorization with teams to manage artifacts 
  • you can create local, remote and virtual repositories



Artifactory can be integrated with many Continuous integration and Continuous delivery tools. Artifactory is mainly used by Ant, Maven and Gradle build tools. Let us see how to install Artifactory on Ubuntu 22.0.4 using Deb packages.

Pre-requisites:
  • VM needs to have at least 4GB RAM, for AWS choose at least medium instance type.
  • Default ports 8081 and 8082 needs to be opened. 8081 for Artifactory REST APIs. 8082 for everything else (UI, and all other product’s APIs).
Change Host Name to Artifactory
sudo hostnamectl set-hostname Artifactory

Update Ubuntu OS
sudo apt update

Add JFrog Artifactory APT repository
echo "deb https://releases.jfrog.io/artifactory/artifactory-debs xenial main" | sudo tee -a /etc/apt/sources.list.d/artifactory.list


Import repository GPG key by running the following commands
curl -fsSL  https://releases.jfrog.io/artifactory/api/gpg/key/public|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/artifactory.gpg

Update the package
sudo apt update

Install Artifactory
sudo apt install jfrog-artifactory-oss -y
The above message should confirm Artifactory have been successfully installed.
Now let us start Artifactory service.

Start Artifactory 
sudo systemctl start artifactory.service
Create symbolic link
sudo systemctl enable artifactory.service


Check whether Artifactory is running?
sudo systemctl status artifactory.service

Press q to quit 

You can also check the logs

sudo tail -f /var/opt/jfrog/artifactory/log/artifactory-service.log


Check if service is running locally on 8081 port

curl localhost:8081

Access Artifactory App
Go to browser and open public IP/DNS name along with port no:8081
http://your_public_dns_name:8081

You should see Artifactory welcome page, login with default username and password which is
admin/password



After Login, click on Get started. 

Now reset admin password. enter as Admin1234/Admin1234

Skip for base URL and skip proxy setup
Click Next, click on Finish


That's it! Artifactory is setup successfully.

How to Integrate Artifactory and Jenkins?
https://www.coachdevops.com/2020/04/integrate-artifactory-with-jenkins.html

You can watch the steps in details on our YouTube channel:
  

Tuesday, January 11, 2022

Install SonaType Nexus 3 using Docker Compose | Install SonaType Nexus 3 using Docker on Ubuntu 22.0.4 | Install Nexus 3 using Docker-Compose

How to setup SonaType Nexus 3 using Docker compose?

Nexus is open source, binary repository manager and Java based tool. It can be installed quickly using Docker with less manual steps.

What is Docker Compose?
Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration. Since Docker Compose lets you configure related containers in a single YAML file, you get the same Infrastructure-as-Code abilities as Kubernetes. But they come in a simpler system that’s more suited to smaller applications that don’t need Kubernetes’ resiliency and scaling.
 
The purpose of docker-compose is to function as docker cli but to issue multiple commands much more quickly. To make use of docker-compose, you need to encode the commands you were running before into a docker-compose.yml file
 
Run docker-compose up to run the entire app.

Watch Steps in YouTube channel:

Pre-requisites:

  • Ubuntu EC2 up and running with at least t2.medium(4GB RAM), 2GB will not work
  • Port 8081, 8085 is opened in security firewall rule
  • instance should have docker and docker-compose installed

Change Host Name to Nexus
sudo hostnamectl set-hostname Nexus

Perform System update
sudo apt update

Install Docker-Compose
sudo apt install docker-compose -y

Add current user to Docker group
sudo usermod -aG docker $USER

Create docker-compose.yml
this yml has all the configuration for installing Nexus on Ubuntu EC2.
sudo vi docker-compose.yml 

(Copy the below code high-lighted in yellow color)
version: "3"
services:
  nexus:
    image: sonatype/nexus3
    restart: always
    volumes:
      - "nexus-data:/sonatype-work"
    ports:
      - "8081:8081"
      - "8085:8085"
volumes:
  nexus-data: {}

Save the file by entering :wq!

Now execute the compose file using Docker compose command to start Nexus Container
sudo docker-compose up -d 


-d means detached mode

Make sure Nexus 3 is up and running
sudo docker-compose logs --follow


Once you see the message, that's it. Nexus 3 is been setup successfully. Now press Control C and enter to come out of the above screen.

How to get Nexus admin password?
Now access Nexus UI by going to browser and enter public dns name with port 8081
Now to go to browser --> http://change to_nexus_publicdns_name:8081

We need to login to Nexus docker container to get Nexus admin password.

Identify Docker container name
sudo docker ps


Get admin password by executing below command
sudo docker exec -it ubuntu_nexus_1 cat /nexus-data/admin.password


Please follow below steps for integrating Nexus 3 with Jenkins

Monday, February 22, 2021

Automate Docker builds using Jenkins Pipelines | Dockerize PHP App | Upload Docker Image from Jenkins into Nexus Docker Registry

We will learn how to automate Docker builds using Jenkins Pipeline. We will use PHP based application. I have already created a repo with source code + Dockerfile. We will see how to create Docker image and upload docker image into Nexus Docker registry successfully. 

- Automating builds
- Automating Docker image builds
- Automating Docker image upload into Nexus docker registry
- Automating Docker container provisioning
 
Watch here for YouTube channel:

Pre-requisites:
1. Jenkins is up and running
2. Docker installed on Jenkins instance. Click here to for integrating Docker and Jenkins
3. Docker and Docker pipelines plug-in are installed
4. Nexus is up and running and docker registry is configured. Click here to know how to do that.
5. port 80 is opened up in firewall rules to access phpApp running inside Docker container

Create an entry in Manage Credentials for connecting to Nexus
Go to Jenkins --> Manage Jenkins--> Click on Manage Credentials.

Enter Nexus user name and password with ID as nexus
Click on Save.

Step # 1 - Create a pipeline in Jenkins, name can be anything



Step # 2 - Copy the pipeline code from below
Make sure you change red highlighted values below:
Your account_d should be updated and repo should be updated.

pipeline {
    
    agent any
    
    environment {
        imageName = "myphpapp"
        registryCredentials = "nexus"
        registry = "ec2-13-58-223-172.us-east-2.compute.amazonaws.com:8085"
        dockerImage = ''
    }
    
    stages {
        stage('Code checkout') {
            steps {
                checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '', url: 'https://bitbucket.org/ananthkannan/phprepo/']]])                   }
        }
    
    // Building Docker images
    stage('Building image') {
      steps{
        script {
          dockerImage = docker.build imageName
        }
      }
    }

    // Uploading Docker images into Nexus Registry
    stage('Uploading to Nexus') {
     steps{  
         script {
             docker.withRegistry( 'http://'+registry, registryCredentials ) {
             dockerImage.push('latest')
          }
        }
      }
    }
    
    // Stopping Docker containers for cleaner Docker run
    stage('stop previous containers') {
         steps {
            sh 'docker ps -f name=myphpcontainer -q | xargs --no-run-if-empty docker container stop'
            sh 'docker container ls -a -fname=myphpcontainer -q | xargs -r docker container rm'
         }
       }
      
    stage('Docker Run') {
       steps{
         script {
                sh 'docker run -d -p 80:80 --rm --name myphpcontainer ' + registry + imageName
            }
         }
      }    
    }
}

Step # 3 - Click on Build - Build the pipeline
Once you create the pipeline, click on Build now.


Steps # 4 - Check Docker images are uploaded into Nexus Registry
Login to Nexus, click on your repo, now you should see the image got uploaded.


Steps # 5 - Access PHP App in the browser which is running inside docker container
Once build is successful, go to browser and enter http://public_dns_name
You should see page like below:




Wednesday, August 26, 2020

How to change default port number in Sonatype Nexus 3? | Change default port number in SonaType Nexus 3 | Change default port number in Nexus

The default port number for Sonatype Nexus is 8081. It can be changed though by modifying the below properties file.

$install-dir/nexus/etc/nexus-default.properties

Modify the desired port no in the above file. once you modify, you need to restart Nexus service to take effect.

sudo service nexus stop

sudo service nexus start

sudo service nexus status


Click here to see steps for how to install Nexus on Redhat.
Click here to see steps for how to install Nexus on Ubuntu.

Monday, August 3, 2020

How to configure Nexus 3 as private Docker Registry | How to host private Docker Registry in Nexus 3

Nexus 3 is one of the popular binary repository managers. It can be also used to store Docker images as well besides storing binaries such as WARs, EARs, Jars, DLLs and Exes.

Let us see how to configure Nexus to host as private Docker registry.

Pre-requisites:
  • Make sure Nexus is successfully configured, it is up and running.
  • Also do open port 8085 open as well besides port 8081 for Nexus.
  • Docker is setup and running.
Steps to configure Nexus 3 as Docker Registry:

1. Login to Nexus and click on Server Administration link at the top of the window. Click on Repositories.







2. Now click on create repository



3. Choose docker hosted repository


4. Choose the value as mentioned:


5. Click on Create repository.

Configure Realm
6. Move Docker Bearer Token realm to right by clicking on >

This settings allows docker repository to have anonymous read enabled.


7. after moving save it.

Please click below link to know how to create Docker image and push docker images into Nexus

Thursday, April 23, 2020

Install JFrog Artifactory on Ubuntu | Setup JFrog Artifactory on Ubuntu | Install JFrog Artifactory 7.X on Ubuntu 18.0.4

Artifactory is one of the popular binary repository managers. It is Java based open source tool, used for storing artifacts.

Artifactory can be integrated with many Continuous integration and Continuous delivery tools. Artifactory is mainly used by Ant, Maven and Gradle build tools. Let us see how to install Artifactory on Ubuntu 18.0.4.

Pre-requisites:
Install Artifactory on 4GB RAM, for AWS choose at least medium instance type.
Default ports 8081 and 8082 needs to be opened.
8081 for Artifactory REST APIs.
8082 for everything else (UI, and all other product’s APIs).

Change Host Name to Artifactory
sudo hostnamectl set-hostname Artifactory

Update Ubuntu OS
sudo apt update

Install Java Open JDK 11 package
sudo apt install default-jdk -y

Download Artifactory 
Add artifactory repository key and file to Ubuntu.
sudo wget -qO - https://api.bintray.com/orgs/jfrog/keys/gpg/public.key | sudo apt-key add - 

sudo add-apt-repository "deb [arch=amd64] https://jfrog.bintray.com/artifactory-debs $(lsb_release -cs) main"
Update the package
sudo apt-get update

Install Artifactory
sudo apt install jfrog-artifactory-oss -y
The above message should confirm Artifactory have been successfully installed.
Now let us start Artifactory service.

Start Artifactory 
sudo systemctl start artifactory.service

Create symbolic link
sudo systemctl enable artifactory.service


Check whether Artifactory is running?
sudo systemctl status artifactory.service
Check if service is running locally on 8081 port
curl localhost:8081

Access Artifactory App
Go to browser and open public IP/DNS name along with port no:8081
http://your_public_dns_name:8081

You should see Artifactory welcome page, login with default username and password which is
admin/password


After Login, click on Get started. Now reset admin password. enter as Admin123/Admin123

Skip for base URL and skip proxy setup
Click Next

That's it! Artifactory is setup successfully.

How to Integrate Artifactory and Jenkins?
https://www.coachdevops.com/2020/04/integrate-artifactory-with-jenkins.html

You can watch the steps in details on my YouTube channel:
 

Tuesday, February 25, 2020

How to upload Docker images into Nexus docker Registry | Upload Docker images to Nexus Decker Registry

How to upload Docker images into Nexus docker Registry - Upload Docker images to Nexus Decker Registry.

Pre-Requistes:

Make sure Docker is installed and up and running.
Nexus is up and running and Docker registry is already is configured. If you have not yet, click here to setup Nexus 3 to configure as Docker Registry.

Steps to configure in Docker to upload Docker images to Nexus:

Configure Docker service to use insecure registry with http.Create Docker daemon file if it does not exist.

sudo vi /etc/docker/daemon.json
Add entries like below:
Enter NExus URL along with port number used for Docker registery


{
    "insecure-registries" : ["nexus_public_dns_name:8085"]
}


Restart Docker daemon after above configuration changes.

sudo systemctl restart docker

Make sure Docker was able to restart successfully.


Login to Docker Registry hosted in Nexus 3

Make sure you are able to login to Docker Registry hosted in Nexus by executing below command:
sudo docker login -u admin nexus_public_dns_name:8085
and then enter nexus admin password


Download Dockerized code from my repo

git clone https://bitbucket.org/ananthkannan/mydockerrepo; cd mydockerrepo/pythonApp

Create a Docker image and tag the image per Nexus Registry
sudo docker build . -t nexus_public_dns_name:8085/mypythonimage


Push the image into Docker Registry
sudo docker push nexus_public_dns_name:8085/mypythonimage


Verify in Nexus if images are uploaded
Login to Nexus, click on Browse, choose Docker registry

Tuesday, February 11, 2020

Unable to upload WAR file into Nexus, Not Authorized error

 Unable to upload WAR file into Nexus,  Not Authorized error 


Root cause and Fix:
Make sure you are using right credentials for Nexus which is admin/admin123, and also you need to select from drop down. And also make sure you select Nexus 3 if you are using Nexus3.

Master DevSecOps and Multi Cloud Computing Course by Coach AK | DevSecOps and Cloud Computing Online Classes | Sep 2025 Schedule

  Master DevSecOps and cloud Computing Bootcamp Schedule for Sep 2025 Are you ready to  supercharge your career  in  DevSecOps ? Whether you...