๐ก SSH
- gradle plugin for easy deployment
Deliver your distribution to remoter server.
- From zero-config to full customization.
In root project build.gradle.kts
file:
plugins {
id("online.colaba.ssh") version "1.9.9"
}
group = "online.colaba"
That's all!
This task will copy folders & files from local machine to remote host ~/${project.name}/... folder
You can set host, or it will be computed from
project.group
(example above)
tasks {
scp {
host = "my-domain.com"
}
}
gradle scp
- Register new task in your
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"
}
- Run this task:
gradle customSshTask
There must be id_rsa private key in root of your project.
- To generate it on local machine (password will be requested) and put it to remote server:
cd .ssh
ssh-keygen -m PEM -t rsa -b 2048
ssh-add id_rsa
ssh-copy-id -i id_rsa.pub root@my-server.com
By default you have preconfigured tasks:
ssh
- all options aredisabled
by default (false)scp
- all options areenabled
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}/nuild/libs/___.jar file to remote server in every subproject- and others:
ssh-ngix
,ssh-briker
,ssh-elasticsearch
,ssh-docker
...
Run gradle tasks
to see the full list in groups ssh
, docker-main-${project.name}
.
- There will be as many tasks as gradle subprojects.
ssh-backend
- copy backend distribution*.jar
-file to remote serverssh-frontend
- copy frontend folder to remote serverssh-nginx
- copy nginx folder to remote server- ...
Name of service for all tasks equals to ${project.name}
You can customize these properties:
ssh {
host = "hostexample.com"
directory = "copy_me_to_remote"
nginx = true
}
- There could be as many backends as you need.
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
|- ...
With ssh
plugin you have additional bonus task to help you with deploying applications with docker
:
compose
- docker compose up all docker-services(gradle subprojects) with recreate and rebuild;compose-nginx
,compose-backend
,compose-frontend
... - docker compose up subproject;prune
- remove unused docker data;cmd
- execute a command line process [linux/windows].
tasks{
cmd { command = "echo ${project.name} ๐ง" }
}