Raising your own Nexus Maven repository on OpenShift

    image


    Recently, articles about OpenShift began to appear on Habré, which attracted my attention, because the platform is really interesting and it’s a sin not to dig into it, and it so happened that I began to think about finding an alternative to my cozy Dropbox-repository Maven in connection with the cancellation of the ability to have direct Public links and folders as a whole (proof: habrahabr.ru/post/145864 ).

    So, today we are going to install a Nexus-based Maven repository for our own needs, and your humble servant will share the crutches of knowledge acquired as a pioneer in this matter.



    Introduction


    First of all, we need to register and create an application, this process is well described in the article habrahabr.ru/post/145203 , I will only give a brief summary:
    1. We register by reference , if you have not done so before;
    2. Create a DIY application (for example, I created a habr application with namespace trylogic)
    3. Further in the application settings we add our ssh-key.
    4. We execute git clone, as it is written on the page. For example, I have:
      $ git clone ssh://a3cf48bc92174721a2c49fd823243b3a@habr-trylogic.rhcloud.com/~/git/habr.git/
      

    Pay attention to the address provided in the link for cloning (something similar to hash@app_name-namespace.rhcloud.com), it will be useful to us for further access to the application via ssh.

    Tomcat


    Why did I choose Tomcat, you ask, and did not use the JBoss container already configured for us by the OpenShift team? Yes, because Nexus does not work in it :)

    Despite the presence of an article on Habr that describes the installation process of Tomcat, I decided to use the article on the OpenShift website , they chewed better there, and there are steps to set up IP and ports for those with Tomcat th works mediocre.
    For those who do not speak English (or just someone too lazy :)) I will try again briefly
    1. Remember I talked about the git link? We use it to log in via ssh to our server (For Windows users, I recommend using Putty):
      ssh a3cf48bc92174721a2c49fd823243b3a@habr-trylogic.rhcloud.com
      
    2. Disable the standard Ruby stub:
      sh ~/habr/repo/.openshift/action_hooks/stop
      # Где habr - имя Вашего инстанса. 
      
    3. We execute it sequentially (we follow the name of the application, my example uses habr):
      cd ~/habr/data
      wget http://www.bizdirusa.com/mirrors/apache/tomcat/tomcat-7/v7.0.27/bin/apache-tomcat-7.0.27.tar.gz
      tar zxvf apache-tomcat-7.0.27.tar.gz
      rm apache-tomcat-7.0.27.tar.gz
      env |grep INTERNAL_IP
      
    4. If the right phase of the moon is now, we, having executed the last command, will receive the IP address of our server. Save it somewhere, it will be useful to us now.
    5. I will be grateful in the comments of sed who will replace what is needed, and I will show how to fix the server.xml file manually. Only vim is on the server, so nano fans will have to tolerate:
      $ vim ~/habr/data/apache-tomcat-7.0.27/conf/server.xml
      
    6. Change IP and ports:
      • on the

      • on the

      • on the

      • on the

      • on the

    7. Tomcat has its own manager out of the box, it’s a sin not to use it. Add to ~ / habr / data / apache-tomcat-7.0.27 / conf / tomcat-users.xml
      After which the manager will be available at http: // YOUR_APP_LINK / manager /
    8. In the folder with your recently downloaded git repository, go to the .openshift / action_hooks folder . Edit the start file to look like this:
      # не забываем заменить habr на ваше имя приложения
      ~/habr/data/apache-tomcat-7.0.27/bin/startup.sh 
      
      And also the stop file:
      ~/habr/data/apache-tomcat-7.0.27/bin/shutdown.sh 
      
      This will allow you to start and stop the server through
      rhc app start -a habr
    9. Do not forget to commit and send (push) your changes


    Not so briefly, of course, but better than never :)


    Nexus


    Finally we come to the hero of our story - a Sonatype product called Nexus.

    It would seem that it can be difficult to easily install an application in a JavaEE container, I thought, and without hesitation, I deployed Nexus into a fresh Tomcat. Naturally, nothing earned $) Reading the logs showed that Nexus is trying to create the $ {user.home} / sonatype-work folder , but OpenShift has a different opinion on this subject, and it does not give write rights to USER_HOME, but we have write access only 3 folders: data, repo and tmp. NE GUSTO, I thought, at least we could replace the Java Property “user.home” with some data thread, but the platform is very fresh, maybe screwed.

    Bearing in mind the information received, which, by the way, is useful not only for Nexus, but also for other Java applications writing in USER_HOME, let's proceed:
    1. Open our Tomcat Manager (see above)
    2. Download the Nexus war distributor: www.sonatype.org/downloads/nexus-2.0.5.war
    3. While it is swinging, we click on the Undeploy application, in which Path is specified as /
    4. After waiting for the download, rename the downloaded nexus-2.0.5.war file to ROOT.war
    5. specify it in the manager via Select WAR file to upload and click deploy
    6. At the end we should see
      OK - Deployed application at context path /
      
    7. Again we go to the server via SSH, where we need to edit the plexus.properties file by running the command
      # сами знаете, что там про замену habr на ваше имя приложения ;)
      vim habr/data/apache-tomcat-7.0.27/webapps/ROOT/WEB-INF/plexus.properties 
      
      where you need to fix the nexus-work parameter
      nexus-work=${user.home}/habr/data/sonatype-work/nexus
      
    8. Save, proudly go to Tomcat Manager, click Start on our Nexus Application. Koshak should report that everything started up fine and our Nexus is available at http: // YOUR_APP_LINK /. If this does not happen - write in the comments, I will help to figure it out.


    Conclusion


    Thus, we learned how to correctly launch our applications in the Tomcat container using the Nexus example. What are my impressions of OpenShift, you say? Extremely positive! The machines are very responsive, there is access via ssh, it is possible to install whatever you like there yourself (if only the souls of the soul worked correctly with the environment;)), 1GB is enough for the programmer’s everyday needs, plus the channel, apparently, is about 10mb per instance, so I threw files with the server pretty quickly.

    Thank you for your attention,
    admin!

    Also popular now: