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 798b824
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions {{ cookiecutter.project_slug }}/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ define START_DOCKER_CONTAINER
if [ `$(DOCKER) inspect -f {% raw -%}{{.State.Running}}{%- endraw %} $(CONTAINER_NAME)` = "false" ] ; then
$(DOCKER) start $(CONTAINER_NAME)
fi

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

###########################################################################################################
Expand Down Expand Up @@ -52,6 +61,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 798b824

Please sign in to comment.