Skip to content

Commit

Permalink
Make some target runnable only in host machine
Browse files Browse the repository at this point in the history
  • Loading branch information
takahi-i committed Mar 23, 2018
1 parent 3670613 commit f73ed72
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions {{ cookiecutter.project_slug }}/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ if [ `$(DOCKER) inspect -f {% raw -%}{{.State.Running}}{%- endraw %} $(CONTAINER
fi
endef

define CHECKIF_HOST_PYSCRIPT
import os, sys
if "COOKIECUTTER_INSIDE_CONTAINER" in os.environ:
print("ERROR: you are in docker container")
sys.exit(-1)
else:
print("INFO: you are not in docker container")
sys.exit(0)
endef

###########################################################################################################
## VARIABLES
###########################################################################################################
Expand All @@ -32,6 +42,7 @@ export DOCKER=docker
{%- endif %}
export PRINT_HELP_PYSCRIPT
export START_DOCKER_CONTAINER
export CHECKIF_HOST_PYSCRIPT
export PYTHONPATH=$PYTHONPATH:$(PWD)
export IMAGE_NAME= {{ cookiecutter.project_slug }}
export CONTAINER_NAME= {{ cookiecutter.project_slug }}
Expand All @@ -52,6 +63,7 @@ init-data: ## download data
-aws s3 sync $(DATA) ./data/

init-docker: ## initialize docker image
@python -c "$$CHECKIF_HOST_PYSCRIPT"
$(DOCKER) build -t $(CONTAINER_NAME) -f ./docker/Dockerfile .

create-container: ## create docker container
Expand Down
2 changes: 1 addition & 1 deletion {{ cookiecutter.project_slug }}/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ FROM nvidia/cuda:8.0-cudnn5-devel-ubuntu16.04
FROM ubuntu:16.04
{%- endif %}

ENV COOKIECUTTER_INSIDE_CONTAINER true
RUN apt-get update && apt-get install -y \
git \
python3.5 \
Expand All @@ -22,5 +23,4 @@ RUN echo "alias python=python3" >> $HOME/.bashrc && \
echo "alias pip=pip3" >> $HOME/.bashrc

WORKDIR /work

ENTRYPOINT ["/bin/bash"]

0 comments on commit f73ed72

Please sign in to comment.