Last active
January 1, 2022 16:40
-
-
Save tseho/66a852e6a515a85cbb35b8ab5ec1ec0f to your computer and use it in GitHub Desktop.
DOTENV in Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If there is a .env file, create a temporary copy of it, in a format supported by Makefile | |
# where every variable become a fallback. "FOO=bar" becomes "FOO?=bar" | |
ifneq (,$(wildcard ./.env)) | |
DOTENV_PATH=/tmp/$(shell echo $$(pwd) | base64) | |
include $(shell cat .env | grep -v --perl-regexp '^('$$(env | sed 's/=.*//'g | tr '\n' '|')')\=' | sed 's/=/?=/g' > $(DOTENV_PATH); echo '$(DOTENV_PATH)') | |
endif | |
# Expose all defined variables to subprocesses. | |
export | |
# Then, other targets | |
.PHONY: up | |
up: | |
docker-compose up -d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment