visit
When you run git push
, deploy the latest master
branch distribution to the server without preparations on the server-side.
If you have a remote Linux server you must have the id_rsa file.
When setting up a remote Linux server, you’ll need to decide upon a method for securely connecting to it. While passwords are one way of verifying a user’s identity, passwords have multiple vulnerabilities and can be cracked by a brute force attack. Secure Shell keys — better known as SSH keys — are often used instead of passwords, as they offer a more secure method of connecting to remote Linux servers. As part of the Secure Shell cryptographic network protocol, SSH keys also enable users to securely perform network services over an unsecured network, such as delivering text-based commands to a remote server or configuring its services.
If you don’t have this key let’s create it - run this commands on your local machine:
Now you need to copy the file ~/.ssh/id_rsa from the local machine into the root of your project which you need to deploy.
In root project build.gradle.kts
file:
plugins {
id("online.colaba.ssh") version "1.8.17"
}
group = "online.colaba"
This task will copy folders & files from local machine to remote host ~/${project.name}/... folder
You can set host, or it will computed from
project.group
(example above)
tasks {
scp {
host = "colaba.online"
}
}
gradle scp
build.gradle.kts
:register("customSshTask", Ssh::class) {
host = "my-domain.com"
user = "root"
gradle = true
frontend = false
docker = true
nginx = true
directory = "distribution"
run = "cd ${project.name} && echo \$PWD"
}
gradle customSshTask
ssh
plugin:ssh
- all options are disabled
by default (false)scp
- all options are enabled
by default (true)ssh-gradle
- copy gradle needed files to remote server in every subprojectssh-docker
- copy docker files to remote serverssh-jars
- copy ${subproject}/build/libs/___.jar file to remote server in every subprojectssh-backend
- copy backend distribution *.jar
-file to remote serverssh-frontend
- copy frontend folder to remote serverssh-nginx
- copy nginx folder to remote serverName of service for all tasks equals to ${project.name}
project
|-[backend]
| - [src/main/java/build/libs]/*.jar
| - Dockerfile
| - Dockerfile.dev
| - docker-compose.yml
| - docker-compose.dev.yml
| - ...
|-[backend-2]
| - [src/main/koltin/build/libs]/*.jar
| - ...
|-[backend-3]
| - [src/main/scala/build/libs]/*.jar
| - ...
|-[frontend]
| - docker-compose.yml
| - ...
|-[nginx]
| - ...
|-[postgres]
| - [backups]
| - ...
|-[elastic]
| - ...
|-[static]
| - ...
|-[gradle]
| - [wrapper]
|- gradlew
|- gradlew.bat
|- docker-compose.yml
|- ...