-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
45 lines (39 loc) · 971 Bytes
/
Makefile
File metadata and controls
45 lines (39 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
COMPOSE_PROJECT_NAME := dev-env
USERNAME := $(shell whoami)
USERID := $(shell id -u)
SERVICES := $(shell docker-compose ps --services)
RUNNING_SERVICES := $(shell docker-compose ps --services --filter "status=running")
USER_PWD := $(shell pwd)
export COMPOSE_PROJECT_NAME
export USERNAME
export USERID
export SERVICES
export RUNNING_SERVICES
export USER_PWD
define waitport
while ! nc -z localhost $(1); do sleep 0.2; done;
endef
define startcompose
if [ -z "$(RUNNING_SERVICES)" ] || [ "$(SERVICES)" = "$(RUNNING_SERVICES)" ]; then \
docker-compose up --build -d; \
fi
endef
# init docker compose
init:
docker-compose up --build -d
# stop docker container
down:
docker-compose down
# shell into docker container as user
cli:
@$(call startcompose)
@chmod u=rw,g=,o= docker/id_rsa
@$(call waitport, 22222)
@ssh \
-A \
-o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
-tv \
-p 22222 \
-i docker/id_rsa \
$(USERNAME)@localhost