docker_build.py 2.62 KB
Newer Older
kladko's avatar
kladko committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
#!/usr/bin/env python

# ------------------------------------------------------------------------------
# Bash script to build cpp-ethereum within TravisCI.
#
# The documentation for cpp-ethereum is hosted at http://cpp-ethereum.org
#
# ------------------------------------------------------------------------------
# This file is part of cpp-ethereum.
#
# cpp-ethereum is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cpp-ethereum is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cpp-ethereum.  If not, see <http://www.gnu.org/licenses/>
#
# (c) 2016 cpp-ethereum contributors.
# ------------------------------------------------------------------------------
#
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
# Copyright (C) 2019-Present SKALE Labs

# This file is part of sgxwallet.

# sgxwallet is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# sgxwallet is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with sgxwallet.  If not, see <https://www.gnu.org/licenses/>.
kladko's avatar
kladko committed
43
#
44
#    @file  docker_build.py
kladko's avatar
kladko committed
45
#    @author Stan Kladko
46
#    @date 2020
kladko's avatar
kladko committed
47 48 49
#

import sys, os, subprocess, time
50

kladko's avatar
kladko committed
51
os.chdir("..")
kladko's avatar
kladko committed
52
topDir = os.getcwd() + "/sgxwallet"
53 54 55
BRANCH = sys.argv[1]
DOCKER_FILE_NAME = sys.argv[2]
IMAGE_NAME = sys.argv[3]
56
COMMIT_HASH = sys.argv[4]
57 58 59
if (BRANCH == "develop"):
    TAG_POSTFIX = "latest"
else:
kladko's avatar
kladko committed
60
    TAG_POSTFIX = "latest_commit"
kladko's avatar
kladko committed
61

62 63
FULL_IMAGE_TAG = "skalenetwork/" + IMAGE_NAME + ":" + TAG_POSTFIX
COMMIT_HASH_TAG = "skalenetwork/" + IMAGE_NAME + ":" + COMMIT_HASH
kladko's avatar
kladko committed
64

kladko's avatar
kladko committed
65
print("Starting build for branch " + BRANCH, flush=True)
kladko's avatar
kladko committed
66

67
assert subprocess.call(["pwd"]) == 0
kladko's avatar
kladko committed
68

kladko's avatar
kladko committed
69
assert subprocess.call(["docker", "build", topDir, "--file", topDir + "/" + DOCKER_FILE_NAME, "--tag",
70
                        FULL_IMAGE_TAG]) == 0
71

72 73
if (BRANCH == "develop"):
    assert subprocess.call(["docker", "tag", FULL_IMAGE_TAG, COMMIT_HASH_TAG]) == 0