Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sage
Path: blob/develop/docker/update-env.sh
4055 views
1
#!/bin/sh
2
3
# This script gets called from CI to establish the name of the current docker
4
# tag to build and also the image which is used to seed the cache.
5
6
# ****************************************************************************
7
# Copyright (C) 2018 Julian Rüth <[email protected]>
8
#
9
# This program is free software: you can redistribute it and/or modify
10
# it under the terms of the GNU General Public License as published by
11
# the Free Software Foundation, either version 2 of the License, or
12
# (at your option) any later version.
13
# http://www.gnu.org/licenses/
14
# ****************************************************************************
15
16
set -ex
17
18
# The maintainer of the CI environment, e.g., the people administrating the
19
# SageMath account on gitlab.com, can decide to inject an arbitrary
20
# base64-encoded script early into the CI execution. The script has access to
21
# all the CI variables, e.g., to find out which job is being executed, and
22
# it could do things such as "exit 1" to fail early, or "git merge" a fix for a
23
# known bug in CI. The CI_MONKEY_PATCH could of course also curl a more
24
# complicated script and execute that.
25
if [ -n "$CI_MONKEY_PATCH" ]; then
26
SCRIPT=$(echo "$CI_MONKEY_PATCH" | base64 -d)
27
$SCRIPT
28
fi
29
30
# From the docker documentation: "A tag name must be valid ASCII and may
31
# contain lowercase and uppercase letters, digits, underscores, periods and
32
# dashes. A tag name may not start with a period or a dash and may contain a
33
# maximum of 128 characters."
34
export DOCKER_TAG=`echo $DOCKER_TAG | tr -d '[:space:]' | tr -c '[:alnum:]_.-' '-' | sed 's/^[-.]*//' | cut -c1-128`
35
36
[[ -z "$DOCKER_TAG" ]] && export DOCKER_TAG=none
37
[[ "$DOCKER_TAG" = "master" ]] && export DOCKER_TAG=latest
38
39
export DOCKER_IMAGE_CLI=${DOCKER_NAMESPACE:-sagemath}/sagemath:$DOCKER_TAG
40
export DOCKER_IMAGE_DEV=${DOCKER_NAMESPACE:-sagemath}/sagemath-dev:$DOCKER_TAG
41
42
export DOCKER_IMAGE_BINDER="${DOCKER_NAMESPACE:-sagemath}/sagemath:${CI_COMMIT_SHA}"
43
44
# Seed the build cache with this image (set to source-clean to build from
45
# scratch.)
46
export ARTIFACT_BASE=${ARTIFACT_BASE:-$DEFAULT_ARTIFACT_BASE}
47
48