Makefile include .env
How to include .env or other make files in a Makefile

.env
in MakefileToday I learned that you can include the .env
file in the Makefile using the include
directive. This will expose all environment variables in the provided .env
file in your Makefile. Using this approach, you can also include another make file.
include .env
# Run mysql database in docker using variables from `.env` file
.PHONY: run-mysql-database
run-mysql-database:
@echo "Running mysql database ${DB_NAME} in docker container ${DB_CONTAINER_NAME}..."
@./run-mysql-docker.sh ${DB_CONTAINER_NAME} ${DB_SERVER_PORT}
.env
in MakefileYou can read more about Make include
directive from the official documentation:
GNU make
GNU make
This short post is part of my Today I Learned series. You can find more here.