From a7ba45c4ad1270a76b1dd7d12b952183b70f08d8 Mon Sep 17 00:00:00 2001 From: hulamy Date: Mon, 26 Sep 2022 16:38:19 +0200 Subject: [PATCH] makefile added down rule + makefile change back to user instead of home --- Makefile | 11 +++++++---- srcs/.env | 4 ++++ srcs/docker-compose.yml | 8 ++++---- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 843314d..c5c88b0 100644 --- a/Makefile +++ b/Makefile @@ -29,10 +29,9 @@ COMPOSE = ./srcs/docker-compose.yml #V_USER = $(shell echo $(USER)) # gives root when make is run with sudo #V_USER = $(shell who | head -1 | tr " " "\n" | head -1) # gives bad result when in `sudo su` #V_USER = $(shell who | head -1 | cut -d " " -f 1) # gives bad result when in `sudo su` -#V_USER = $(shell users | tr " " "\n" | head -1) -V_HOME = $(HOME) -VOLUMES_D = $(V_HOME)/data/wp_volume \ - $(V_HOME)/data/db_volume +V_USER = $(shell users | tr " " "\n" | head -1) +VOLUMES_D = /home/$(V_USER)/data/wp_volume \ + /home/$(V_USER)/data/db_volume # list of running containers, see : https://stackoverflow.com/questions/10024279/how-to-use-shell-commands-in-makefile RUNNING = $(shell docker ps -q) @@ -45,6 +44,7 @@ VOLUMES = $(shell docker volume ls -q) all: build up volumes: + sed -i "s/^LOGIN=.*/LOGIN=$(V_USER)/g" ./srcs/.env mkdir -p $(VOLUMES_D) build: @@ -53,6 +53,9 @@ build: up: volumes docker-compose -f $(COMPOSE) up -d +down: + docker-compose -f $(COMPOSE) down + # list images, containers, volumes list: @echo $(B_YELLOW)"\nimages:"$(RESET) diff --git a/srcs/.env b/srcs/.env index d3dca66..2562296 100644 --- a/srcs/.env +++ b/srcs/.env @@ -1,4 +1,8 @@ +# DOCKER-COMPOSE + +LOGIN=hulamy + # MARIADB SETUP DB_HOST=mariadb diff --git a/srcs/docker-compose.yml b/srcs/docker-compose.yml index ef7ab1f..1db27b8 100644 --- a/srcs/docker-compose.yml +++ b/srcs/docker-compose.yml @@ -78,15 +78,15 @@ volumes: driver_opts: type: none o: "bind" - device: ${HOME}/data/wp_volume -# device: /home/${LOGIN}/data/wp_volume + device: /home/${LOGIN}/data/wp_volume +# device: ${HOME}/data/wp_volume db_volume: driver: local driver_opts: type: none o: "bind" - device: ${HOME}/data/db_volume -# device: /home/${LOGIN}/data/db_volume + device: /home/${LOGIN}/data/db_volume +# device: ${HOME}/data/db_volume networks: inception: