Let's create a plugin using the wizard

$ athena wizard start
       ___   __  __
      /   | / /_/ /_  ___  ____  ____ _
     / /| |/ __/ __ \/ _ \/ __ \/ __  /
    / ___ / /_/ / / /  __/ / / / /_/ /
   /_/  |_\__/_/ /_/\___/_/ /_/\__,_/
                              v0.4.0
  ==================================


Welcome to the plugin creator wizard.

[Plugin] what is the name of the plugin?
simple-webserver

[Plugin:simple-webserver] how many commands do you want do add?
1

[Plugin:simple-webserver] what is the name of the command #1? (Cannot contain spaces or underscore and should be in lowercase)
start

[Command:start] what is the description?
Starts the webserver.

[Command:start] will you require a docker container (Y/n)?


[Command:start] do you want to create your own container (Y/n)?
n

[Command:start] what will be the image that you will be using, e.g.: debian:jessie, ubuntu:latest, php:7.0-apache, etc...
php:7.0-apache

[Command:start] will the container run as a daemon(y/N)?
y

[Command:start] will you execute some tasks after the container starts/executes (y/N)?


[Command:start] how many mandatory arguments does it have *(0)?
2

[Command:start] what is the name of the argument #1?
source directory

[Command:start] what is the name of the argument #2?
port

[Command:start] do you want to save (Y/n)?


[OK] Command 'start' was created for plugin 'simple-webserver'.

[INFO] To use it execute "athena simple-webserver start"

Using the plugin for the first time

$ athena simple-webserver
       ___   __  __
      /   | / /_/ /_  ___  ____  ____ _
     / /| |/ __/ __ \/ _ \/ __ \/ __  /
    / ___ / /_/ / / /  __/ / / / /_/ /
   /_/  |_\__/_/ /_/\___/_/ /_/\__,_/
                              v0.4.0
  ==================================
  [simple-webserver v1.0.0]
  ----------------------------------

[INFO] Athena plugin 'simple-webserver' has not been initialized!
[INFO] Athena plugin 'simple-webserver' is initialising...

usage: athena simple-webserver <command> [arg...]

These are the available commands for plugin [simple-webserver]:
        start  Starts the webserver.

Execute the start command without parameters

$ athena simple-webserver start
       ___   __  __
      /   | / /_/ /_  ___  ____  ____ _
     / /| |/ __/ __ \/ _ \/ __ \/ __  /
    / ___ / /_/ / / /  __/ / / / /_/ /
   /_/  |_\__/_/ /_/\___/_/ /_/\__,_/
                              v0.4.0
  ==================================
  [simple-webserver v1.0.0]
  ----------------------------------

usage: athena simple-webserver start <source_directory> <port>

Code generated by the wizard plus a few additions

CMD_DESCRIPTION="Starts the webserver."

athena.usage 2 "<source_directory> <port>"

# arguments are found below
source_directory="$(athena.path 1)"
port="$(athena.int 2)"

# clearing arguments from the stack
athena.pop_args 2

# options for container are found below
athena.plugin.use_external_container_as_daemon "php:7.0-apache"

# mounts the specified dir into the container
athena.docker.mount_dir "$source_directory" "/var/www/html"

# maps the specified port into the port 80 of the container
athena.docker.add_option -p "$port:80"

Execute the command with the right parameters

$ athena simple-webserver start ~/tech-demo  80 --athena-dbg
       ___   __  __
      /   | / /_/ /_  ___  ____  ____ _
     / /| |/ __/ __ \/ _ \/ __ \/ __  /
    / ___ / /_/ / / /  __/ / / / /_/ /
   /_/  |_\__/_/ /_/\___/_/ /_/\__,_/
                              v0.4.0
  ==================================
  [simple-webserver v1.0.0]
  ----------------------------------

[DEBUG] starting container athena-plugin-simple-webserver-0 for command 'start' ...

[DEBUG] Time: 0 minutes and 0 seconds elapsed.

Run the info command to check if the container is running

$ athena info
       ___   __  __
      /   | / /_/ /_  ___  ____  ____ _
     / /| |/ __/ __ \/ _ \/ __ \/ __  /
    / ___ / /_/ / / /  __/ / / / /_/ /
   /_/  |_\__/_/ /_/\___/_/ /_/\__,_/
                              v0.4.0
  ==================================


[INFO] Running containers [image|container|status]:

 * php  athena-plugin-simple-webserver-0  [UP]  To access it use http://192.168.99.100:80


[INFO] No custom images were found!

Now check the browser, and voilá it's working:

image

results matching ""

    No results matching ""