This repository was archived by the owner on Dec 17, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 18
First reorganization #16
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
*.log | ||
|
||
# Generated files | ||
*/scripts/common | ||
|
||
# Editor files | ||
*.sw[po] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
all: check_postinstall | ||
.PHONY: all build clean docker-clean sagemath-develop-test | ||
|
||
# Images and their dependencies | ||
IMAGES=sagemath sagemath-develop sagemath-jupyter sagemath-patchbot | ||
|
||
sagemath: sagemath/install_sage.sh sagemath/postinstall_sage.sh | ||
common_scripts:=$(wildcard common/*.sh) | ||
common_script_copies:=$(addprefix %/scripts/, $(common_scripts)) | ||
scripts=$(common_script_copies) | ||
|
||
sagemath-develop: sagemath/install_sage.sh sagemath/postinstall_sage.sh | ||
all: build | ||
|
||
sagemath: %: $(scripts) | ||
|
||
sagemath-develop: %: $(scripts) | ||
|
||
sagemath-jupyter: sagemath | ||
|
||
|
@@ -18,6 +24,9 @@ build: $(IMAGES) | |
push: | ||
for image in $(IMAGES); do docker push sagemath/$$image; done | ||
|
||
clean: | ||
for image in $(IMAGES); do rm -rf $(image)/scripts/common; done | ||
|
||
# Refs: | ||
# - https://www.calazan.com/docker-cleanup-commands/ | ||
# - http://stackoverflow.com/questions/17236796/how-to-remove-old-docker-containers | ||
|
@@ -31,12 +40,15 @@ docker-clean: | |
|
||
# Takes care of common file that we need to duplicate in several subdirectories | ||
# See https://github.com/docker/docker/issues/1676 | ||
%/postinstall_sage.sh: postinstall_sage.sh | ||
cp $< > $@ | ||
|
||
|
||
sagemat%: sagemat%/Dockerfile FORCE | ||
echo Building sagemath/$@ | ||
$(common_script_copies): $(common_scripts) | ||
@echo "Copying $< > $@" | ||
mkdir -p $(@D) | ||
head -1 $< > $@ | ||
echo "# !!! GENERATED FILE: DO NOT MODIFY! !!!" >> $@ | ||
tail -n +2 $< >> $@ | ||
|
||
$(IMAGES): %: %/Dockerfile FORCE | ||
@echo Building sagemath/$@ | ||
time docker build --tag="sagemath/$@" $@ 2>&1 | tee [email protected] | ||
|
||
FORCE: | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/bin/bash | ||
# !!!NOTE!!! This script is intended to be run with root privileges | ||
# It will run as the 'sage' user when the time is right. | ||
SAGE_SRC_TARGET=${1%/} | ||
BRANCH=$2 | ||
|
||
if [ -z $SAGE_SRC_TARGET ]; then | ||
>&2 echo "Must specifiy a target directory for the sage source checkout" | ||
exit 1 | ||
fi | ||
|
||
if [ -z $BRANCH ]; then | ||
>&2 echo "Must specify a branch to build" | ||
exit 1 | ||
fi | ||
|
||
N_CORES=$(cat /proc/cpuinfo | grep processor | wc -l) | ||
|
||
export SAGE_FAT_BINARY="yes" | ||
export MAKE="make -j${N_CORES}" | ||
cd "$SAGE_SRC_TARGET" | ||
git clone --depth 1 --branch ${BRANCH} https://github.com/sagemath/sage.git | ||
chown -R sage:sage sage | ||
cd sage | ||
|
||
# Sage can't be built as root, for reasons... | ||
# Here -E inherits the environment from root, however it's important to | ||
# include -H to set HOME=/home/sage, otherwise DOT_SAGE will not be set | ||
# correctly and the build will fail! | ||
sudo -H -E -u sage make || exit 1 | ||
|
||
# Put scripts to start gap, gp, maxima, ... in /usr/bin | ||
./sage --nodotsage -c "install_scripts('/usr/bin')" | ||
|
||
# Add aliases for sage and sagemath | ||
ln -sf "${SAGE_SRC_TARGET}/sage/sage" /usr/bin/sage | ||
ln -sf "${SAGE_SRC_TARGET}/sage/sage" /usr/bin/sagemath | ||
|
||
# Setup the admin password for Sage's lecacy notebook to avoid need for later | ||
# user interaction | ||
# This should also be run as the 'sage' user to ensure that the resulting | ||
# configuration is written to their DOT_SAGE | ||
sudo -H -u sage ./sage <<EOFSAGE | ||
from sage.misc.misc import DOT_SAGE | ||
from sagenb.notebook import notebook | ||
directory = DOT_SAGE+'sage_notebook' | ||
nb = notebook.load_notebook(directory) | ||
nb.user_manager().add_user('admin', 'sage', '', force=True) | ||
nb.save() | ||
quit | ||
EOFSAGE | ||
|
||
# Clean up artifacts from the sage build that we don't need for runtime or | ||
# running the tests | ||
# | ||
# Unfortunately none of the existing make targets for sage cover this ground | ||
# exactly | ||
make misc-clean | ||
make -C src/ clean | ||
rm -rf upstream/ | ||
rm -rf src/doc/output/doctrees/ |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,12 @@ FROM ubuntu:wily | |
|
||
MAINTAINER Sebastian Gutsche <[email protected]> | ||
|
||
ARG SAGE_SRC_TARGET=/opt | ||
# Note: SAGE_BRANCH may also be a tag name | ||
ARG SAGE_BRANCH=develop | ||
|
||
RUN apt-get update -qq \ | ||
&& apt-get install -y wget build-essential m4 dpkg-dev sudo python libssl-dev git \ | ||
&& apt-get install -y wget build-essential automake m4 dpkg-dev sudo python libssl-dev git \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
|
@@ -12,24 +16,19 @@ RUN adduser --quiet --shell /bin/bash --gecos "Sage user,101,," --disabled-pa | |
&& adduser sage sudo \ | ||
&& chown -R sage:sage /home/sage/ | ||
|
||
USER sage | ||
|
||
COPY scripts/ /tmp/scripts | ||
RUN chmod -R +x /tmp/scripts | ||
# make source checkout target, then run the install script | ||
# see https://github.com/docker/docker/issues/9547 for the sync | ||
|
||
ADD install_sage.sh /tmp/install_sage.sh | ||
RUN sudo chown sage:sage /tmp/install_sage.sh \ | ||
&& chmod +x /tmp/install_sage.sh \ | ||
RUN mkdir -p $SAGE_SRC_TARGET \ | ||
&& /tmp/scripts/common/install_sage.sh $SAGE_SRC_TARGET $SAGE_BRANCH \ | ||
&& sync \ | ||
&& /tmp/install_sage.sh | ||
|
||
ADD postinstall_sage.sh /tmp/postinstall_sage.sh | ||
RUN sudo chown sage:sage /tmp/postinstall_sage.sh \ | ||
&& chmod +x /tmp/postinstall_sage.sh \ | ||
&& sync \ | ||
&& /tmp/postinstall_sage.sh | ||
|
||
&& rm -rf /tmp/scripts | ||
|
||
USER sage | ||
ENV HOME /home/sage | ||
WORKDIR /home/sage | ||
|
||
EXPOSE 8080 | ||
|
||
CMD [ "sage" ] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,12 @@ FROM ubuntu:wily | |
|
||
MAINTAINER Sebastian Gutsche <[email protected]> | ||
|
||
ARG SAGE_SRC_TARGET=/opt | ||
# Note: SAGE_BRANCH may also be a tag name | ||
ARG SAGE_BRANCH=7.0 | ||
|
||
RUN apt-get update -qq \ | ||
&& apt-get install -y wget build-essential m4 dpkg-dev sudo python libssl-dev \ | ||
&& apt-get install -y wget build-essential automake m4 dpkg-dev sudo python libssl-dev git \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
|
@@ -12,22 +16,16 @@ RUN adduser --quiet --shell /bin/bash --gecos "Sage user,101,," --disabled-pa | |
&& adduser sage sudo \ | ||
&& chown -R sage:sage /home/sage/ | ||
|
||
USER sage | ||
|
||
COPY scripts/ /tmp/scripts | ||
RUN chmod -R +x /tmp/scripts | ||
# make source checkout target, then run the install script | ||
# see https://github.com/docker/docker/issues/9547 for the sync | ||
|
||
ADD install_sage.sh /tmp/install_sage.sh | ||
RUN sudo chown sage:sage /tmp/install_sage.sh \ | ||
&& chmod +x /tmp/install_sage.sh \ | ||
RUN mkdir -p $SAGE_SRC_TARGET \ | ||
&& /tmp/scripts/common/install_sage.sh $SAGE_SRC_TARGET $SAGE_BRANCH \ | ||
&& sync \ | ||
&& /tmp/install_sage.sh | ||
|
||
ADD postinstall_sage.sh /tmp/postinstall_sage.sh | ||
RUN sudo chown sage:sage /tmp/postinstall_sage.sh \ | ||
&& chmod +x /tmp/postinstall_sage.sh \ | ||
&& sync \ | ||
&& /tmp/postinstall_sage.sh | ||
&& rm -rf /tmp/scripts | ||
|
||
USER sage | ||
ENV HOME /home/sage | ||
WORKDIR /home/sage | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note--I've reworked this script so that it is run as root (before the
USER sage
command in the Dockerfile). This gives it freedom to perform operations that should be done as root, like creating links in/usr/bin/
. However it runs the sage build as the sage user.This means there's actually no reason for the sage user to be in the sudoers list in the first place, and we could remove that entirely (though this PR doesn't do that yet).