Provides Rebar3 Templates for creating Erlang based project structures.
If you prefer to try it without installing localy, you can use Docker container (Docker should be installed):
$ docker run --name r3tmpl --rm -it aialferov/r3tmpl
To learn more about the container see its image Dockerfile.
Proceed to the Usage section if you wish to skip local installation.
Either clone this repository directly to the Rebar3 Templates folder:
$ git clone https://github.com/aialferov/r3tmpl ~/.config/rebar3
or use Make to install (but still need to clone to somewhere):
$ make install
Assuming you have Erlang already installed, Rebar3 is also obviously needed to use templates. Download and install:
$ wget https://s3.amazonaws.com/rebar3/rebar3
$ install rebar3 /usr/local/bin
To create a project skeleton from template:
$ rebar3 new <Type> <Name>
The following types are supported:
- aalib — library template
- aacli — command line interface tool template
- aasvc — service executable template.
A project will be given a specified name.
Let's create an Erlang based simple service:
$ rebar3 new aasvc mysvc
===> Writing mysvc/rebar3
===> Writing mysvc/rebar.config
===> Writing mysvc/Makefile
===> Writing mysvc/Dockerfile
===> Writing mysvc/README.md
===> Writing mysvc/src/mysvc.erl
===> Writing mysvc/src/mysvc_test.erl
===> Writing mysvc/src/mysvc.app.src.script
===> Writing mysvc/priv/mysvc.config
===> Writing mysvc/mk/Erlanglib.mk
===> Writing mysvc/mk/Erlangbin.mk
===> Writing mysvc/mk/Docker.mk
===> Writing mysvc/mk/Kubernetes.mk
===> Writing mysvc/mk/Version
$ tree mysvc
mysvc
├── Dockerfile
├── Makefile
├── README.md
├── mk
│ ├── Docker.mk
│ ├── Erlangbin.mk
│ ├── Erlanglib.mk
│ ├── Kubernetes.mk
│ └── Version
├── priv
│ └── mysvc.config
├── rebar.config
├── rebar3
└── src
├── mysvc.app.src.script
├── mysvc.erl
└── mysvc_test.erl
3 directories, 14 files
You can already build and run the service:
$ cd mysvc
$ make
$ make run
The latter command executes the service binary located in "_build/default/bin" directory after build. You can also run it manually.
If you run inside a Docker container started the way described in the Try section, do not forget to copy the project (if you want to keep it) over your host machine before exiting the shell:
$ docker cp r3tmpl:/mysvc ./
The "uninstall" target removes only those files supplied within this repository from the "~/.config/rebar3" folder and the folder itself if empty:
$ make uninstall
To remove the templates manually:
$ rm -rf ~/.config/rebar3/templates/{aa{lib,cli,svc}*,mk}
$ rmdir -p ~/.config/rebar3/templates