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
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
source directory
[Command:start] what is the name of the argument
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>"
source_directory="$(athena.path 1)"
port="$(athena.int 2)"
athena.pop_args 2
athena.plugin.use_external_container_as_daemon "php:7.0-apache"
athena.docker.mount_dir "$source_directory" "/var/www/html"
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: