Konstantin Sivakov
By Konstantin Sivakov

Ahoy Commands

Ahoy Commands

AHOY!

This tool is very useful for automating and organizing your projects giving own CLI app with zero code and dependencies and can speed up your development.

1
2
3
$ ahoy up

translates to

1
2
3
4
5
$ docker-compose build

$ docker-compose start

Installation

Instalation script for Linux user:


sudo wget -q https://github.com/devinci-code/ahoy/releases/download/1.1.0/ahoy-`uname -s`-amd64 -O /usr/local/bin/ahoy && sudo chown $USER /usr/local/bin/ahoy && chmod +x /usr/local/bin/ahoy

Usage

The ahoy commands are specified in .ahoy.yml file placed in your root directory of your project.

The file can be initialized with command:

1
2
3
$ ahoy init

ahoy.yml example

One example for your docker-compose environment

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
ahoyapi: v2

  

  commands:

    up:

      usage: Build and start project.

      cmd: |

        docker-compose up -d "$@"

    stop:

      usage: Stops the project

      cmd: |

        docker-compose stop "$@"

  

    down:

      usage: Delete project (CAUTION).

      cmd: |

        if [ "$1" == "y" ]; then

          docker-compose down --volumes

        else

          ahoy confirm "Running this command will destroy your

          current site, database and build? 

          Are you sure you didn't mean ahoy stop?" &&

          # Run this if confirm returns true

          docker-compose down --volumes ||

          # Run this if confirm returns false

          echo "OK, probably a wise choice..."

        fi

  

    build:

      usage: Build project.

      cmd: |

        docker-compose up -d --build "$@"

    cli:

      usage: Start a shell inside a container.

      cmd: docker-compose exec "$@" sh

    copy-config:

      usage: Copy config file to container | ahoy copy-config FILE CONTAINER

      cmd: docker cp $1 $(docker-compose ps -q $2):/app/config

    dump-db:

      usage: Creates dump of your datbase container using custom script

      cmd: |

         source ./scripts/database_dump.sh