May 7

Push 2 Prod: my lastest project

Hello everyone !
I recently build a command line tool in ruby.

In this post I will introduce it and ask you what do you think about it !

It's a project that don't have any goals, that is written in 2 weeks and in a new language for me so be indulgent...
It's called Push 2 Prod (p2p) and it helps you to deploy any application to a distant server in one command !

Push2Prod

How it works ?

Push 2 Prod uses ssh and so, you don't need any software on the distant machine...
With a .p2p file, that tells instructions and commands, p2p will start an ssh connection with the distant host and execute what you've precised in the file.

Command line tool

How to try it ?

You can install it on Linux based os.
You need the following (aptitude) packages:

  • ruby, gem and bundle
  • ping
  • openssh
  • scp
  • curl

Run

curl https://raw.githubusercontent.com/camarm-dev/p2p/main/install.sh | sudo sh
Enter fullscreen mode Exit fullscreen mode

And p2p is installed !

Add my first server

Using

p2p servers add
Enter fullscreen mode Exit fullscreen mode

You will be able to register your first server by following the wizard.
You can now see it in the server list

p2p servers list
Enter fullscreen mode Exit fullscreen mode

And view it with

p2p servers spec <srv-name>
Enter fullscreen mode Exit fullscreen mode

Create my first p2p deployment

The p2p 'language' is pretty simple and look like Dockerfile. 4 instructions are possible:

  • DIST: connect to the remote host (ex: DIST production-server)
  • CTX: change the remote context / directory (ex: CTX /root)
  • COPY: copy comma separated files to the remote (ex: COPY config.ini,main.py)
  • COMMAND: execute a shell command on the distant server (ex: COMMAND python3 main.py)

A simple example

DIST backend
CTX /app
COMMAND git pull & service backend restart
Enter fullscreen mode Exit fullscreen mode

Launch deployment

The command

p2p -e
Enter fullscreen mode Exit fullscreen mode

will execute the p2p deployment.

Full documentation is available here

Tips

You can get help on a specific command or a group of command by typing

p2p help <COMMAND>
Enter fullscreen mode Exit fullscreen mode

eg:

p2p servers help spec
Enter fullscreen mode Exit fullscreen mode
p2p help -e
Enter fullscreen mode Exit fullscreen mode

You can update p2p with

p2p update
Enter fullscreen mode Exit fullscreen mode

Thanks

Thank you for reading ! Now tell me what do you thing about p2p ? For any bugs or suggestion, open an issue on github, I will implement it and push a new release.
Have a nice code,
Goodbye 👋 !