makefile added down rule

+ makefile change back to user instead of home
This commit is contained in:
hulamy
2022-09-26 16:38:19 +02:00
parent 67c0bd1a40
commit a7ba45c4ad
3 changed files with 15 additions and 8 deletions

View File

@@ -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 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 | 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 who | head -1 | cut -d " " -f 1) # gives bad result when in `sudo su`
#V_USER = $(shell users | tr " " "\n" | head -1) V_USER = $(shell users | tr " " "\n" | head -1)
V_HOME = $(HOME) VOLUMES_D = /home/$(V_USER)/data/wp_volume \
VOLUMES_D = $(V_HOME)/data/wp_volume \ /home/$(V_USER)/data/db_volume
$(V_HOME)/data/db_volume
# list of running containers, see : https://stackoverflow.com/questions/10024279/how-to-use-shell-commands-in-makefile # list of running containers, see : https://stackoverflow.com/questions/10024279/how-to-use-shell-commands-in-makefile
RUNNING = $(shell docker ps -q) RUNNING = $(shell docker ps -q)
@@ -45,6 +44,7 @@ VOLUMES = $(shell docker volume ls -q)
all: build up all: build up
volumes: volumes:
sed -i "s/^LOGIN=.*/LOGIN=$(V_USER)/g" ./srcs/.env
mkdir -p $(VOLUMES_D) mkdir -p $(VOLUMES_D)
build: build:
@@ -53,6 +53,9 @@ build:
up: volumes up: volumes
docker-compose -f $(COMPOSE) up -d docker-compose -f $(COMPOSE) up -d
down:
docker-compose -f $(COMPOSE) down
# list images, containers, volumes # list images, containers, volumes
list: list:
@echo $(B_YELLOW)"\nimages:"$(RESET) @echo $(B_YELLOW)"\nimages:"$(RESET)

View File

@@ -1,4 +1,8 @@
# DOCKER-COMPOSE
LOGIN=hulamy
# MARIADB SETUP # MARIADB SETUP
DB_HOST=mariadb DB_HOST=mariadb

View File

@@ -78,15 +78,15 @@ volumes:
driver_opts: driver_opts:
type: none type: none
o: "bind" 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: db_volume:
driver: local driver: local
driver_opts: driver_opts:
type: none type: none
o: "bind" 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: networks:
inception: inception: