Distribution of Java applications

Surprisingly, but the fact is the distribution of Java applications in the 21st century still a huge crutch. The developers still come up with ways like rsync/copy-paste/wget to install java applications on the server. And only monstrous enterprise production ready platforms sometimes allow you to do a little more to roll back the app to previous version. In this article I would like to tell you about an affordable and simple way of organizing the distribution.
the
deb and apt
In the world there are a lot of really giant repository of tools and applications in their distribution. The biggest decrease is AppStore, Google Play, Debian/Ubuntu repositories, and CentOS/Fedora YUM repository. For example, in the Ubuntu repository for version 15.04 contains about 90,000 applications (excluding different versions). Why not take advantage of proverennoi time system and for the distribution of Java applications? Especially because:
— most servers and so use the Debian/Ubuntu
— a time-tested tool: the first release was 16 years ago
— native support in the operating system
First, a little about the distribution system applications in Debian/Ubuntu. It consists of two main parts:
— deb packages
— apt (Advanced Package Tool) tools
the
deb packages
deb is a binary distribution of the application. It consists of 3 main parts:
— meta-information. Manufacturer, version, dependencies on other packages (much like maven), description, etc.
directly app. .tar.gz archive
— (optional) scripts to be executed during the installation
Structure .tar.gz the archive can be absolutely arbitrary. However, to make sure Your app looks like all other applications of the system, it should follow the directory structure of the Debian/Ubuntu:
— /etc — configs
— /etc/init.d/ script start the daemons.
/usr/bin — executable files
/usr/lib — libraries
/var/log — logs
Depending on Your application directories may differ slightly, but the overall structure of hope is clear.
Another important feature of the deb packages is the ability to run scripts during installation. These scripts are also stored in a deb package and have a standard naming Convention. Each script can be executed in a particular phase of installation. The installation package is divided into several phases:
— preinst
— inst
— postinst
— prerm
— rm
— postrm
There are many different intermediate phases and various combinations of the status of the installation. Us they have little interest in, but for those who want to understand, you can read official documentation. Typically, these scripts set up the rotation and archiving of logs, set the initial values of the configurations (for example, the root password for mysql). If you have the ultimate business application, it is better to take some normal automation tool like Ansible, Chief, Puppet.
the
apt
apt is a set of tools for working with deb packages. It allows you to:
— configure the repository and work with them: add, delete, change, update, index
— manage packages: to install, remove, update, search,
apt repository in a simplified form is an HTTP server which distributes the deb packages. It has an index (file), which is available through the standard path and the binaries, the path to which is in the index.
the
Tying it all together
After it became clear the approximate scheme of the ligament deb + apt, you can try to shintemirova. An exemplary scheme is as follows:
— create deb package in the package phase.
— publication of the resulting package in the deploy phase
There are several maven plugins.
the
jdeb
— list the files and directories that will be in the result .tar.gz archive
— specify permissions and
More complete documentation on the capabilities of the plugin you can find on the official .
the
apt-maven-plugin
Working with the repository specified in distributionManagement how apt repository instead of maven repository. Although nothing prevents to use them at the same time under one url. Their layout's compatible with each other.
An example configuration looks as follows:
the
<plugin>
<groupId>com.aerse.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>deploy</id>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
<configuration>
<component>main</component>
<codename>strepo</codename>
</configuration>
</plugin>
The distributionManagement section (nothing unusual):
the
<distributionManagement>
<repository>
<id>maven-release-repo</id>
<url>http://example.com/maven</url>
</repository>
</distributionManagement>
After performing phase-deploy, example.com/maven will be the apt repository. And you can safely write:
the
sudo add-apt-repository "deb http://example.com/maven strepo main"
sudo apt-get update
sudo apt-get install <artifactId>
the
a Little of my favourite enterprise
Manz any java enterprise developer is as follows:
— security
— stability
— high availability, production ready platform
All this is perfectly solved, if you arrange apt repository of the most popular hosting for developers: s3. Coupled with cloudfront, it gives a guarantee 99.9% reliability and geographic raspredelennoi.
This is done again quite easily. It is necessary to connect the plugin to work with the s3:
the
<build>
<extensions>
<extension>
<groupId>org.springframework.build</groupId>
<artifactId>aws-maven</artifactId>
<version>5.0.0.RELEASE</version>
</extension>
</extensions>
...
</build>
To change the url in the distributionManagement section in the name bucket'a:
the
<distributionManagement>
<repository>
<id>maven-release-repo</id>
<url>s3://example.bucket</url>
</repository>
</distributionManagement>
And configure the access to your bucket':
the
<servers>
<server>
<id>maven-release-repo</id>
<username>apikey</username>
<password>apisecret</password>
</server>
...
</servers>
On the target server to access the repository there is a special plugin: apt-transport-s3. Unfortunately it is not yet in the official repositories, so you need to manually add one of the repositories where it contains:
the
sudo add-apt-repository ppa:leonard-ehrenfried/apt-transport-s3
sudo apt-get install apt-transport-s3
Then you can already specify our s3 repository:
the
sudo add-apt-repository "deb s3://apikey:apisecret@s3.amazonaws.com/example.bucket strepo main"
the
total
As a result of all manipulations, the installation of the application:
— mvn clean deploy
On any Debian/Ubuntu server, anywhere in the world:
— apt-get update
— apt-get install artifactId
Комментарии
Отправить комментарий