The following operations are based on a cloud under the server and domain name, no server and domain name can be engaged, I have not tried!
Install the Docker
Before you can start installing LVM2, you need to install both device-mapper-Persistent-Data and LVM2 dependencies.
Device-mapper-persistent-data is a storage driver for Linux. It is an advanced storage technology for Linux. Lvm is used to create logical disk partitions. CentOS Yum package manager is used to install two dependencies:
yum install -y yum-utils device-mapper-persistent-data lvm2
Copy the code
After installing the dependency, we added the Docker image source of Ali Cloud. Can speed up Docker installation.
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo yum install docker-ce -yCopy the code
Once installed, we can start Docker using systemctl startup. Systemctl is a Linux process management service command that can help us start docker
systemctl start docker
systemctl enable docker
Copy the code
Then run the docker -v command, which can be used to view the version information of the Docker installation. Of course, it can also help us check the docker installation status. If the version information is displayed, Docker is successfully installed.
Configuration making request
Docs. Drone. IO/server/prov…
Client ID and Client Secret need to be copied and saved. Client Secret is hidden after it is generated, so it is best to copy and paste it into a small book.
Openssl generates a shared key
openssl rand -hex 16
bea26a2221fd8090ea38720fc445eca6
Copy the code
Install the drone
docker pull drone/drone:2
Copy the code
Run the drone
docker run \
--volume=/var/lib/drone:/data \
--env=DRONE_GITHUB_CLIENT_ID=your-id \ Id # in the making
--env=DRONE_GITHUB_CLIENT_SECRET=super-duper-secret \ # github generated key
--env=DRONE_RPC_SECRET=super-duper-secret \ This is the shared key generated by OpenSSL
--env=DRONE_SERVER_HOST=drone.company.com \ This address is the address of drone's visual operation page. If the following is not port 80, it should be drone.company.com:3333
--env=DRONE_SERVER_PROTO=https \ This is also HTTP without a certificate
--publish=80:80 \ Port # 80 is generally reserved for nginx and can be replaced with a 3333:80
--publish=443:443 \ "HTTPS" is not configured
--env=DRONE_USER_CREATE=username:yourname,admin:true # This is very important and will be used later
--restart=always \
--detach=true \
--name=drone \ The name of the container
drone/drone:2 # Just downloaded drone image
Copy the code
Go here to access your configurationDRONE_SERVER_HOST
You can see the page: if you can’t see the warehouse list, click on the top rightSYNC
Button to synchronize.
Webhooks
Check for Webhooks in Github repository Settings.
Much like Jenkins, Webhooks are automatically triggered when a code update is submitted to the repository, and Drone will Clone the code from the repository and perform pipelined operations via the.drone.yml configuration (the equivalent of the Pom.xml file used by Java).
Install the runner
Installing the Runner Image
docker pull drone/drone-runner-docker:1
Copy the code
Running runner
docker run --detach \
--volume=/var/run/docker.sock:/var/run/docker.sock \
--env=DRONE_RPC_PROTO=https \ It depends
--env=DRONE_RPC_HOST=drone.company.com \ # drone.company.com:3333
--env=DRONE_RPC_SECRET=super-duper-secret \ # openSSL-generated key
--env=DRONE_RUNNER_CAPACITY=2 \
--env=DRONE_RUNNER_NAME=my-first-runner \
--publish=3000:3000 \
--restart=always \
--name=runner \
drone/drone-runner-docker:1
Copy the code
You can view the logs through Docker logs
docker logs runner Name =runner can be changed
INFO[0000] starting the server INFO[0000] successfully
pinged the remote server
Copy the code
Create a new test repository on Github
You can use an existing one or you can create a new one.
Activate the warehouse
Find the warehouse Settings on Drone to activate and save.
If you don’t have DRONE_USER_CREATE on it, you can’t see trusted, so you push your code and the build will tell you that untrusted is not trusted.
. The drone. Yml file
Configure ssh_host and ssh_password
Drone ensures safe access. We don’t need to output sensitive values such as passwords in plain text in the configuration file. We can add Secret.
host
Configure your server public IP address: password
Configure your SSH password for logging in to the server
Write yML files
I in the yml file configuration, can have a look at the official documentation: docs. Drone. IO/pipeline/ov… The following is a configuration found on the Internet, put your warehouse may not be able to use, but this configuration example is a more perfect step, imitate gourd!
kind: pipeline
type: docker
name: vite-vue3
trigger:
branch:
- master
steps:
# Use cache
- name: restore-cache
image: drillster/drone-volume-cache
settings:
restore: true
mount:
- ./node_modules
volumes:
- name: node_cache
path: /cache
# packaged
- name: build
image: node:16
commands:
- node -v
- yarn -v
- yarn config set registry https://registry.npm.taobao.org -g
- yarn config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/ -g
- yarn
- yarn run build
# update cache
- name: rebuild-cache
image: drillster/drone-volume-cache
settings:
rebuild: true
mount:
- ./node_modules
volumes:
- name: node_cache
path: /cache
# deployment
- name: deploy
image: appleboy/drone-scp
settings:
host:
from_secret: ssh_host # secret = secret
username: root # login name
password:
from_secret: ssh_password # login password
command_timeout: 3m
Set the file address to which the subscriber's files will be deployed
target: /usr/share/nginx/html Copy the project to the target directory
source: dist/* # The directory after packing
rm: true
strip_components: 1
when:
status:
- success
volumes:
- name: node_cache
host:
path: /data/node
Copy the code
Packaging sometimes causes node memory to run out: max_old_space_size can be set
vue-cli-service build --max_old_space_size=4096
Copy the code
Tips: If you are not familiar with the grammar of DRONE and YML file, you can only leave the step of “deployment”. You can pack the DIST file locally and push it to the warehouse, and you can quickly experience the pleasure of “semi-automated deployment”!
If Docker is mismatched
docker ps -a # View all containers
docker stop name/id Stop the container by id or name
docker rm name/id Delete it and start over
Copy the code