toy
toy

Reputation: 12141

How to run bash to var and use that in string in Makefile?

What I want is to run bash command docker-machine ip default put the result in a variable and use that variable in a string and export that variable to environment variable. But that doesn't work out as I expected.

Here's my Makefile so far.

IP := $(docker-machine ip default) 
export DATABASE_URL := "postgres://postgres@$(IP)/postgres"
test:
    echo $(DATABASE_URL)
    py.test tests

When I run make test I get

postgres://postgres@ /postgres

Upvotes: 0

Views: 92

Answers (1)

levif
levif

Reputation: 2176

You need to indicate shell command:

IP := $(shell docker-machine ip default)
$(warning IP=$(IP))

Upvotes: 1

Related Questions