Last active
January 18, 2019 22:56
-
-
Save Quar/ff756377b2ff179e87a156b1e6d43600 to your computer and use it in GitHub Desktop.
a very crude lazy script for dockerized SageMath on macOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set Jupyter Notebook Root Directory on Host to be mounted in Docker | |
# such that all changes within Docker will be saved to local. | |
HOST_JUPYTER_NOTEBOOK_ROOT = $(PWD)/code | |
# if port 8888 on localhost has been used, change to another free port | |
CONTAINER_PORT = 8888 | |
######################################## | |
CONTAINER_NAME = sagemath | |
CONTAINER_CODE_ROOT = /home/sage/code | |
.PHONY: start | |
start: | |
docker run -d \ | |
-p 127.0.0.1:$(CONTAINER_PORT):$(CONTAINER_PORT) \ | |
--name=$(CONTAINER_NAME) \ | |
--rm \ | |
-v $(HOST_JUPYTER_NOTEBOOK_ROOT):$(CONTAINER_CODE_ROOT) \ | |
sagemath/sagemath \ | |
sage --notebook jupyter --notebook-dir $(CONTAINER_CODE_ROOT) \ | |
--no-browser --ip='*' --port=$(CONTAINER_PORT) | |
@echo "==> wait for server up ..." && sleep 3 | |
open `docker logs $(CONTAINER_NAME) 2>&1 | grep 'http://localhost:$(CONTAINER_PORT)/?token='` | |
.PHONY: stop | |
stop: | |
docker stop $(CONTAINER_NAME) | |
.PHONY: clean | |
clean: | |
docker rm $(CONTAINER_NAME) | |
.PHONY: restart | |
restart: | stop clean start | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use, download Makefile in to a folder, and change into the folder, use
make run
to start a dockerized SageMath Jupyter Notebook on macOS (need to have Docker for Mac installed)make restart
to restart.