-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
88 lines (78 loc) · 2.03 KB
/
Makefile
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Docker image used for container
IMAGE=gitpod/workspace-full
# Variables for container name and paths
PROJECT_NAME=$(lastword $(subst /, ,$(PWD)))
LOCAL_PATH=${PWD}
#TEMP_CONTAINER_NAME="${PROJECT_NAME}_$(shell date +'%H%M%S')"
CONTAINER_NAME=${PROJECT_NAME}
CONTAINER_PATH=/workspace/${PROJECT_NAME}
# Common parameters for starting the container
SHARED_START_PARAMS= \
--interactive \
--tty \
--volume=${LOCAL_PATH}:${CONTAINER_PATH}:delegated \
--workdir ${CONTAINER_PATH} \
--publish 80:80 \
--publish 4000:4000 \
--publish 8002:8002
# Detect a package manager for pre-install
ifneq ($(wildcard ./Pipfile),)
INSTALL_CMD=pipenv install
else
ifneq ($(wildcard ./Gemfile),)
INSTALL_CMD=bundle install
else
ifneq ($(wildcard ./Package.json),)
INSTALL_CMD=npm install
else
INSTALL_CMD=echo 'No known package file to install'
endif
endif
endif
.PHONY: start create install run clean
ifeq ($(shell docker container inspect --format='{{.Config.Image}}' ${PROJECT_NAME}),)
start: create install
else
start:
endif
####################################
### STARTING EXISTING CONTAINER ###
####################################
docker start \
--attach \
--interactive \
${PROJECT_NAME}
create:
####################################
### CREATING NEW NAMED CONTAINER ###
####################################
docker create \
--name=${PROJECT_NAME} \
${SHARED_START_PARAMS} \
${IMAGE}
install:
####################################
####### INSTALL DEPENDANCIES #######
####################################
docker start ${PROJECT_NAME}
####################################
docker exec \
--tty \
${PROJECT_NAME} \
bash --login -c "${INSTALL_CMD}"
####################################
docker stop ${PROJECT_NAME}
run:
####################################
# RUNNING TEMPORARY NEW CONTAINER ##
####################################
docker run \
--rm \
${SHARED_START_PARAMS} \
${IMAGE}
clean:
####################################
### REMOVING EXISTING CONTAINER ####
####################################
docker rm \
${PROJECT_NAME}