Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The operation method of installing and deploying Docker management tool Drone in Linux

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Today, I will talk to you about the operation of installing and deploying Docker management tool Drone in Linux, which may not be well understood by many people. in order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.

Drone is an open source continuous integration platform (CI) built on top of Docker. Drone provides a set of pre-built Docker images that support 12 + languages and almost all major databases. This means that you don't have to take the time to install software and configure your build environment. Of course, if you need a highly customized environment, Drone provides enough flexibility to use custom Docker images.

Drone is developed entirely in the GE language. It has the characteristics of fast and efficient.

How is it different from other CI services?

1.Drone is open source

2.Drone is built on top of Docker

3.Drone is easily hosted on its own infrastructure

4.Drone provides a CLI to run the local build, in the Docker container

5.Drone integrates with GitHub by default and will soon support Bitbucket patch

1. Install Docker

First, we will install docker, as this is the most critical element of Drone's workflow. Drone makes good use of docker to build and test applications. Container technology improves the efficiency of application deployment. To install docker, we need to run the following command on different linux distributions, and we will explain Ubuntu 14.04 and CentOS 7 here.

Ubuntu

To install Docker on Ubuntu, we just need to run the following command.

The code is as follows:

# apt-get update

# apt-get install docker.io

After installation, we need to restart the docker engine using the service command.

The code is as follows:

# service docker restart

Then we let docker start automatically when the system starts.

The code is as follows:

# update-rc.d docker defaults

Adding system startup for / etc/init.d/docker...

/ etc/rc0.d/K20docker->.. / init.d/docker

/ etc/rc1.d/K20docker->.. / init.d/docker

/ etc/rc6.d/K20docker->.. / init.d/docker

/ etc/rc2.d/S20docker->.. / init.d/docker

/ etc/rc3.d/S20docker->.. / init.d/docker

/ etc/rc4.d/S20docker->.. / init.d/docker

/ etc/rc5.d/S20docker->.. / init.d/docker

CentOS

First, we need to update the packages that have been installed on the machine. We can use the following command.

The code is as follows:

# sudo yum update

To install docker on centos, we can simply run the following command.

The code is as follows:

# curl-sSL https://get.docker.com/ | sh

After installing the docker engine, we simply use the following systemd command to start docker, because the default initialization system for centos 7 is systemd.

The code is as follows:

# systemctl start docker

Then we need to have docker start automatically when the system starts.

The code is as follows:

# systemctl enable docker

The code is as follows:

Ln-s'/ usr/lib/systemd/system/docker.service''/ etc/systemd/system/multi-user.target.wants/docker.service'

two。 Install the SQlite driver

Drone defaults to using the SQlite3 database server to save data and information. It automatically creates a database called drone.sqlite in / var/lib/drone/ to handle the creation and migration of the database schema. To install SQlite3, we need to complete the following steps.

Ubuntu 14.04

Because SQlite3 exists in the default software library of Ubuntu 14.04, we simply install it using the apt command.

The code is as follows:

# apt-get install libsqlite3-dev

CentOS 7

To install on Centos 7, use the following yum command.

The code is as follows:

# yum install sqlite-devel

3. Install Drone

Finally, we have installed the dependent software, and we are now closer to installing Drone. In this step we simply download the corresponding binary package from the official link and install Drone using the default package manager.

Ubuntu

We will use wget to download drone's debian package from the official Debian file download link. Here are the download commands.

The code is as follows:

# wget downloads.drone.io/master/drone.deb

Resolving downloads.drone.io (downloads.drone.io)... 54.231.48.98

Connecting to downloads.drone.io (downloads.drone.io) | 54.231.48.98 |: 80. Connected.

HTTP request sent, awaiting response... 200 OK

Length: 7722384 (7.4m) [application/x-debian-package]

Saving to: 'drone.deb'

7722384 1.38MB/s in 17s

2015-11-06 14:09:28 (456 KB/s)-'drone.deb' saved [7722384max]

After downloading, we will install it using the dpkg package manager.

The code is as follows:

# dpkg-I drone.deb

Selecting previously unselected package drone.

(Reading database... 28077 files and directories currently installed.)

Preparing to unpack drone.deb...

Unpacking drone (0.3.0-alpha-1442513246)...

Setting up drone (0.3.0-alpha-1442513246)...

Your system ubuntu 14: using upstart to control Drone

Drone start/running, process 9512

CentOS

On the CentOS machine we will use the wget command to download the RPM package from the download link.

The code is as follows:

# wget downloads.drone.io/master/drone.rpm

-- 2015-11-06 11 06RV 45muri-http://downloads.drone.io/master/drone.rpm

Resolving downloads.drone.io (downloads.drone.io)... 54.231.114.18

Connecting to downloads.drone.io (downloads.drone.io) | 54.231.114.18 |: 80. Connected.

HTTP request sent, awaiting response... 200 OK

Length: 7763311 (7.4m) [application/x-redhat-package-manager]

Saving to: 'drone.rpm'

7763311 1.18MB/s in 20s

2015-11-06 11:07:06 (374mm)-'drone.rpm' saved [7763311 KB/s]

Then we use yum to install the rpm package.

The code is as follows:

# yum localinstall drone.rpm

4. Configure Port

After the installation is complete, we have to configure it before we can work. The configuration file for drone is in / etc/drone/drone.toml. By default, the web interface of drone uses 80, which is also the default port of http. If we modify it, please change the corresponding value of the server block in the configuration file as shown below.

The code is as follows:

[server]

Port= ": 80"

5. Integrated Github

In order to run Drone, we must set at least one integration point associated with GitHub, GitHub Enterprise Edition, and Gitlab,Gogs,Bitbucket. We have only integrated github in this article, but if we want to integrate other services, we can make changes in the configuration file. In order to integrate github, we need to create a new application in the settings of github: https://github.com/settings/developers.

To create an application, we need to click Register on the New Application page and fill in the form as shown below.

We should make sure that the authorization callback link is set in the configuration item of the application, and the link looks like http://drone.linoxide.com/api/auth/github.com. Then we click to register the app. When all is done, we will see the client ID and client key that we need to configure in our Drone configuration file.

After all this is done, we need to use a text editor to edit the drone configuration file, such as using the following command.

The code is as follows:

# nano / etc/drone/drone.toml

Then we will find the [github] section in the configuration file of drone, followed by the configuration shown below

The code is as follows:

[github]

Client= "3dd44b969709c518603c"

Secret= "4ee261abdb431bdc5e96b19cc3c498403853632a"

# orgs= []

# open=false

6. Configure the SMTP server

If we want drone to send notifications using email, then we need to set up our SMTP server in the SMTP configuration. If we already have a SMTP service, we just need to simply use its configuration file, but since we don't have a SMTP server, we need to install a MTA such as Postfix, and then configure SMTP in the drone configuration file.

Ubuntu

Use the following apt command to install postfix in ubuntu.

The code is as follows:

# apt-get install postfix

CentOS

Use the following yum command to install postfix in CentOS.

The code is as follows:

# yum install postfix

Once installed, we need to edit our postfix configuration file.

The code is as follows:

# nano / etc/postfix/main.cf

Then we will replace the value of myhostname with our own FQDN, such as drone.linoxide.com.

The code is as follows:

Myhostname = drone.linoxide.com

Now start configuring the SMTP section of the drone configuration file.

The code is as follows:

# nano / etc/drone/drone.toml

Find the [smtp] section to add the contents above and below.

The code is as follows:

[smtp]

Host = "drone.linoxide.com"

Port = "587"

From = "root@drone.linoxide.com"

User = "root"

Pass = "password"

Note: the user and pass parameters here are strongly recommended to be changed to the configuration of a specific user.

7. Configure Worker

As we know that drone leverages docker for build and testing tasks, we need to configure docker as the worker of drone. To do this, you need to modify the [worker] section of the drone configuration file.

The code is as follows:

# nano / etc/drone/drone.toml

Then uncomment the next few lines and add the above and the following.

The code is as follows:

[worker]

Nodes= [

"unix:///var/run/docker.sock"

"unix:///var/run/docker.sock"

]

Here we only set up two nodes, which means that the above configuration file can only perform two build operations at the same time. To improve concurrency, you can increase the value of the node.

The code is as follows:

[worker]

Nodes= [

"unix:///var/run/docker.sock"

"unix:///var/run/docker.sock"

"unix:///var/run/docker.sock"

"unix:///var/run/docker.sock"

]

Using the above configuration file drone is configured to build four tasks at the same time using the local docker daemon.

8. Restart Drone

Finally, when all the installation and configuration are ready, we will now start the drone server on the local linux machine.

Ubuntu

Because ubuntu 14.04 uses sysvinit as the default initialization system, simply execute the following service command to start drone.

The code is as follows:

# service drone restart

For drone to run automatically when the system starts, you need to run the following command.

The code is as follows:

# update-rc.d drone defaults

CentOS

Because CentOS 7 uses systemd as the initialization system, you can restart drone simply by running the following systemd command.

The code is as follows:

# systemctl restart drone

For drone to run automatically, you only need to run the following command.

The code is as follows:

# systemctl enable drone

9. Add firewall exception rule

It is well known that drone uses port 80 by default and we have not modified it, so we need to configure a firewall program to allow port 80 (http) to open and allow other machines to connect through the network.

Ubuntu 14.04

Iptables is the most popular firewall program, and ubuntu installs it by default. We need to modify iptable to expose port 80 so that we can make drone's web interface accessible to everyone on the network.

The code is as follows:

# iptables-An INPUT-p tcp-m tcp-- dport 80-j ACCEPT

# / etc/init.d/iptables save

CentOS 7

Because systemd is installed by default in CentOS 7, it uses firewalld as the firewall program. To open port 80 (http service) on firewalld, we need to execute the following command.

The code is as follows:

# firewall-cmd-permanent-add-service=http

Success

# firewall-cmd-reload

Success

10. Access the web interface

Now we will open drone through the web interface on our favorite browser. To do this, we need to point the browser to the server running drone. Because drone uses port 80 by default and we haven't modified it, we just need to type http://ip-address/ or http://drone.linoxide.com in the browser according to our configuration. After we have done the above correctly, we can see the login interface.

Because Github is configured in the above steps, we now simply select github and go to the application authorization step, and then we can enter the workbench.

Here it synchronizes our code base on github and then asks us which code base we want to build on drone.

When this step is complete, it will ask us to add the new name of the. drone.yml file to the code base, and define the build process and configuration items in this file, such as using that docker image, executing those commands and scripts to compile, and so on.

Let's configure our .drone.yml as follows.

The code is as follows:

Image: python

Script:

-python helloworld.py

-echo "Build has been completed."

After this step is completed, we can use the YAML configuration file in the drone application to build our application. All commits and changes to the code base are synchronized to the repository at this time. Once the submission is complete, drone will automatically start building.

After all the operations are completed, we can see the result of the build on the terminal.

After reading the above, do you have any further understanding of how to install and deploy the Docker management tool Drone in Linux? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report