forked from jelyoussefi/cifar10
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
49 lines (40 loc) · 2.16 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
#----------------------------------------------------------------------------------------------------------------------
# Flags
#----------------------------------------------------------------------------------------------------------------------
SHELL:=/bin/bash
export TERM=xterm
export DOCKER_IMAGE_NAME?=cifar10_image
#----------------------------------------------------------------------------------------------------------------------
# Targets
#----------------------------------------------------------------------------------------------------------------------
default:
docker-proxy:
ifneq ($(HTTP_PROXY),)
@sudo mkdir -p /etc/systemd/system/docker.service.d
@grep -q ${HTTP_PROXY} /etc/systemd/system/docker.service.d/http-proxy.conf > /dev/null 2>&1 || \
sudo bash -c " \
echo '[Service]' > /etc/systemd/system/docker.service.d/http-proxy.conf && \
echo 'Environment=\"HTTP_PROXY=${HTTP_PROXY}\"' >> /etc/systemd/system/docker.service.d/http-proxy.conf && \
echo 'Environment=\"HTTPS_PROXY=${HTTPS_PROXY}\"' >> /etc/systemd/system/docker.service.d/http-proxy.conf && \
echo 'Environment=\"NO_PROXY=localhost,127.0.0.1\"' >> /etc/systemd/system/docker.service.d/http-proxy.conf && \
systemctl daemon-reload && systemctl restart docker"
else
@sudo bash -c "rm -rf /etc/systemd/system/docker.service.d/http-proxy.conf && \
systemctl daemon-reload && systemctl restart docker"
endif
docker-build: docker-proxy
@$(call msg, Building docker image ${DOCKER_IMAGE_NAME} ...)
@docker build -t ${DOCKER_IMAGE_NAME} .
docker-run: docker-build
@$(call msg, Running docker container for ${DOCKER_IMAGE_NAME} image ...)
@docker run -it --rm -a stdout -a stderr --privileged -v /dev:/dev ${DOCKER_IMAGE_NAME}
#----------------------------------------------------------------------------------------------------------------------
# helper functions
#----------------------------------------------------------------------------------------------------------------------
define msg
tput setaf 2 && \
for i in $(shell seq 1 120 ); do echo -n "-"; done; echo "" && \
echo " "$1 && \
for i in $(shell seq 1 120 ); do echo -n "-"; done; echo "" && \
tput sgr0
endef