-
Notifications
You must be signed in to change notification settings - Fork 490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Builds #2558
Builds #2558
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
FROM ubuntu:18.04 | ||
ARG GO_VERSION | ||
FROM quay.io/influxdb/cross-builder:go${GO_VERSION}-latest | ||
|
||
# This dockerfile is capabable of performing all | ||
# build/test/package/deploy actions needed for Kapacitor. | ||
|
@@ -41,35 +42,23 @@ RUN wget -q https://github.com/google/protobuf/releases/download/v${PROTO_VERSIO | |
# Install protobuf3 python library | ||
RUN wget -q https://github.com/google/protobuf/releases/download/v${PROTO_VERSION}/protobuf-python-${PROTO_VERSION}.tar.gz \ | ||
&& tar -xf protobuf-python-${PROTO_VERSION}.tar.gz \ | ||
&& cd /protobuf-${PROTO_VERSION}/python \ | ||
&& cd protobuf-${PROTO_VERSION}/python \ | ||
&& python2 setup.py install \ | ||
&& python3 setup.py install \ | ||
&& cd ../../ \ | ||
&& rm -rf /protobuf-${PROTO_VERSION} protobuf-python-${PROTO_VERSION}.tar.gz | ||
|
||
# Install rust | ||
ENV PATH "/root/.cargo/bin:$PATH" | ||
RUN curl --proto '=https' --tlsv1.2 --tls-max 1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -y && \ | ||
cargo --help | ||
|
||
# Install go | ||
ENV GOPATH /root/go | ||
ENV GO_VERSION 1.15.5 | ||
ENV GO_ARCH amd64 | ||
RUN wget -q https://storage.googleapis.com/golang/go${GO_VERSION}.linux-${GO_ARCH}.tar.gz; \ | ||
tar -C /usr/local/ -xf /go${GO_VERSION}.linux-${GO_ARCH}.tar.gz ; \ | ||
rm /go${GO_VERSION}.linux-${GO_ARCH}.tar.gz | ||
ENV PATH /usr/local/go/bin:$PATH | ||
ENV PROJECT_DIR $GOPATH/src/github.com/influxdata/kapacitor | ||
ENV PKG_CONFIG $PROJECT_DIR/pkg-config.sh | ||
#ENV PKG_CONFIG $PROJECT_DIR/pkg-config.sh | ||
ENV PATH $GOPATH/bin:$PATH | ||
RUN mkdir -p $PROJECT_DIR | ||
WORKDIR $PROJECT_DIR | ||
|
||
VOLUME $PROJECT_DIR | ||
VOLUME /root/go/src | ||
VOLUME /go/src | ||
|
||
# Configure local git | ||
RUN git config --global user.email "[email protected]" | ||
RUN git config --global user.Name "Docker Builder" | ||
|
||
ENTRYPOINT [ "/root/go/src/github.com/influxdata/kapacitor/build.py" ] | ||
ENTRYPOINT [ "/go/src/github.com/influxdata/kapacitor/build.py" ] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,8 +93,8 @@ | |
|
||
supported_builds = { | ||
'darwin': [ "amd64" ], | ||
'linux': [ "amd64", "i386", "armhf", "arm64", "armel", "static_i386", "static_amd64" ], | ||
'windows': [ "amd64", "i386" ] | ||
'linux': [ "arm64", "amd64" ], | ||
'windows': [ "amd64" ] | ||
} | ||
|
||
supported_packages = { | ||
|
@@ -158,7 +158,11 @@ def run_generate(): | |
"""Run 'go generate' to rebuild any static assets. | ||
""" | ||
logging.info("Running generate...") | ||
run("go install -mod=mod github.com/golang/protobuf/protoc-gen-go github.com/benbjohnson/tmpl github.com/mailru/easyjson/easyjson") | ||
run("""go install -mod=mod | ||
github.com/golang/protobuf/protoc-gen-go \ | ||
github.com/benbjohnson/tmpl \ | ||
github.com/mailru/easyjson/easyjson \ | ||
github.com/influxdata/pkg-config""") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in case the kapa has a newer version of pkg-config it wants. |
||
try: | ||
subprocess.check_output(["go", "generate", "./..."]) | ||
except subprocess.CalledProcessError as exc: | ||
|
@@ -382,13 +386,11 @@ def get_system_arch(): | |
arch = os.uname()[4] | ||
if arch == "x86_64": | ||
arch = "amd64" | ||
elif arch == "386": | ||
arch = "i386" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing 32 bit support (sorry!), because flux doesn't support 32 bit. |
||
elif arch == "aarch64": | ||
arch = "arm64" | ||
elif 'arm' in arch: | ||
# Prevent uname from reporting full ARM arch (eg 'armv7l') | ||
arch = "arm" | ||
arch = "arm64" | ||
return arch | ||
|
||
def get_system_platform(): | ||
|
@@ -491,6 +493,7 @@ def build(version=None, | |
nightly=False, | ||
race=False, | ||
clean=False, | ||
cc="", | ||
outdir=".", | ||
tags=[], | ||
static=False): | ||
|
@@ -522,42 +525,39 @@ def build(version=None, | |
logging.info("Building target: {}".format(target)) | ||
build_command = "" | ||
|
||
# Handle static binary output | ||
if static is True or "static_" in arch: | ||
if "static_" in arch: | ||
static = True | ||
arch = arch.replace("static_", "") | ||
build_command += "CGO_ENABLED=0 " | ||
build_command += "CGO_ENABLED=1 " | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We always need cgo now. |
||
|
||
# Handle variations in architecture output | ||
fullarch = arch | ||
if arch == "i386" or arch == "i686": | ||
arch = "386" | ||
elif arch == "aarch64" or arch == "arm64": | ||
if arch == "aarch64" or arch == "arm64": | ||
arch = "arm64" | ||
elif "arm" in arch: | ||
arch = "arm" | ||
build_command += "GOOS={} GOARCH={} ".format(platform, arch) | ||
|
||
if platform == "linux": | ||
if arch == "amd64": | ||
tags += ["netgo", "osusergo", "static_build"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we are defaulting to static building now, because it eliminates a whole class of problems |
||
if arch == "arm64": | ||
cc = "aarch64-unknown-linux-musl-cc" | ||
tags += ["netgo", "osusergo", "static_build", "noasm"] | ||
elif platform == "darwin" and arch == "amd64": | ||
cc = "x86_64-apple-darwin15-clang" | ||
tags += [ "netgo", "osusergo"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't build static on mac. |
||
elif platform == "windows" and arch == "amd64": | ||
cc = "x86_64-w64-mingw32-gcc" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While Influx doesn't officially support the windows build, it would be awesome if someone wanted to test it for me (I don't have a windows machine). |
||
build_command += "CC={} GOOS={} GOARCH={} ".format(cc, platform, arch) | ||
|
||
if "arm" in fullarch: | ||
if fullarch == "armel": | ||
build_command += "GOARM=5 " | ||
elif fullarch == "armhf" or fullarch == "arm": | ||
build_command += "GOARM=6 " | ||
elif fullarch == "arm64": | ||
# GOARM not used - see https://github.com/golang/go/wiki/GoArm | ||
pass | ||
else: | ||
logging.error("Invalid ARM architecture specified: {}".format(arch)) | ||
logging.error("Please specify either 'armel', 'armhf', or 'arm64'.") | ||
if fullarch != "arm64": | ||
logging.error("Invalid ARM architecture specified: {} only arm64 is supported".format(arch)) | ||
return False | ||
if platform == 'windows': | ||
target = target + '.exe' | ||
build_command += "go build -o {} ".format(os.path.join(outdir, target)) | ||
build_command += "go build -buildmode=exe -o {} ".format(os.path.join(outdir, target)) | ||
else: | ||
build_command += "go build -o {} ".format(os.path.join(outdir, target)) | ||
if race: | ||
build_command += "-race " | ||
if len(tags) > 0: | ||
build_command += "-tags {} ".format(','.join(tags)) | ||
build_command += "-tags \"{}\" ".format(' '.join(tags)) | ||
if "1.4" in get_go_version(): | ||
if static: | ||
build_command += "-ldflags=\"-s -X main.version {} -X main.branch {} -X main.commit {} -X main.platform OSS\" ".format(version, | ||
|
@@ -913,7 +913,7 @@ def main(args): | |
type=str, | ||
help='Name to use for package name (when package is specified)') | ||
parser.add_argument('--arch', | ||
metavar='<amd64|i386|armhf|arm64|armel|all>', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No more 32 bit support :-( |
||
metavar='<amd64|arm64|all>', | ||
type=str, | ||
default=get_system_arch(), | ||
help='Target architecture for build output') | ||
|
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.
did arm64 before amd64 because it is more likely to fail