Manala Manala

Recipes for your projects

Lazy - Symfony

Migrations

Requirements

  • Manala CLI to update the recipe
  • Make
  • Docker Desktop 2.2.0+ or Docker Engine + Docker Compose

Setup

Ok, let's init a foo symfony demo application:

manala init -i lazy.symfony foo
cd foo

Up the system and open a shell into an another terminal:

make up
make sh

Create the foo symfony demo application into /tmp and move files into your project (symfony can't create application in a non-empty dir):

symfony new /tmp/foo --no-git --demo
rsync -a /tmp/foo/ ./

Browse http://localhost:8080 and enjoy :)

Usage

Shell

Open a shell to container

make sh

Run commands through container shell

# From file
make sh < file
# Multilines, using heredoc
make sh << 'EOF'
command 1
command 2
...
EOF
# Single line
make sh <<< command

Specify working dir

make sh DIR=/etc <<< pwd
/etc

Makefile

One of the first directive of your project's Makefile should be to include manala recipe Makefile

include .manala/Makefile

Or, if you're not sure manala recipe directory will be present, make it optional. If you do make it optionnal, you'll have to ensure that every parts of you project's Makefile using manala recipe tools could fallback to another solution.

-include .manala/Makefile

Note: it's a good practise to have a .SILENT: as the first line of your project's Makefile. Not only does it globally silence make targets echoing, but it also offers a lowcost debugging system by just commenting it on demand.

.SILENT:
#.SILENT:

A MANALA_DOCKER variable is available to check whether you're inside the container or not

foo:
ifdef MANALA_DOCKER
    echo Inside container
else
    echo Outside container
endif

A MANALA_DIR variable is available to get your project's directory inside container

foo:
    echo Project directory is $(MANALA_DIR)

There are three ways to force your project's Makefile target execution inside container:

  1. Function manala_docker_shell
foo:
    echo Can be run *inside* or *outside* container
    $(call manala_docker_shell, echo Always run *inside* container)
  1. Shell substitution with MANALA_DOCKER_SHELL
foo: SHELL := $(MANALA_DOCKER_SHELL)
foo:
    echo Always run *inside* container

# Or, if you're not sure manala recipe "Makefile" will be included
foo: SHELL := $(or $(MANALA_DOCKER_SHELL),$(SHELL))
foo:
    echo Can be run *inside* or *outside* container, \
        but always *inside* if manala recipe "Makefile" is included
  1. Make substitution with MANALA_DOCKER_MAKE
foo:
    $(MANALA_DOCKER_MAKE) bar

bar:
    echo Run *outside* container if called directly \
        or *inside* container if called from "foo"

An automagic target help system is included out-of-the-box. You can list all available documented commands with make help (or just make, as the help command is the default one)

$ make

Usage: make [command]

Help:
  help This help

System:
  sh    Open a local system shell
  clean Clean local system

You can add your own documented commands, by adding double dashed comments in your projects's Makefile

## This is foo
foo:
    ...

## Bar - Use the "Bar" help section
bar.baz:
    ...
$ make

Usage: make [command]

Help:
  help This help

System:
  sh    Open a local system shell
  clean Clean local system

Commands:
  foo This is foo

Bar:
  bar.baz Use the "Bar" help section