adding in bazel build
Trying to get Bazel to build containers.
This commit is contained in:
33
tools/BUILD
Normal file
33
tools/BUILD
Normal file
@@ -0,0 +1,33 @@
|
||||
load("@io_bazel_rules_docker//container:container.bzl", "container_image")
|
||||
# load("@io_bazel_rules_docker//contrib:test.bzl", "container_test")
|
||||
|
||||
container_image(
|
||||
name = "bladerunner/tools",
|
||||
base = "@alpine_linux_amd64//image",
|
||||
cmd = ["World"],
|
||||
entrypoint = [
|
||||
"echo",
|
||||
"Hello",
|
||||
],
|
||||
env = {
|
||||
"envVar": "My environment variable",
|
||||
"xyz": "321",
|
||||
},
|
||||
files = [
|
||||
"//extended/image_data:Data_file.txt",
|
||||
"//extended/image_data:More_data.txt",
|
||||
"//extended/image_data:file_to_copy.txt",
|
||||
],
|
||||
labels = {
|
||||
"desc": "Description for version 7.7",
|
||||
"version": "7.7",
|
||||
},
|
||||
symlinks = {
|
||||
"/usr/More_data.txt": "/More_data.txt",
|
||||
},
|
||||
tars = ["//extended/image_data:tarfile.tar"],
|
||||
volumes = [
|
||||
"/myVol1",
|
||||
"/usr/myVol2",
|
||||
],
|
||||
)
|
||||
@@ -1,10 +1,10 @@
|
||||
# Set up a packer image in Docker.
|
||||
# Set up a container with the tooling installed.
|
||||
FROM ubuntu:22.04
|
||||
LABEL org.opencontainers.image.authors=kyle@imap.cc
|
||||
|
||||
RUN apt-get update && apt-get -y install git bash curl sudo
|
||||
|
||||
ADD . tools
|
||||
RUN tools/install-dependencies.sh
|
||||
RUN tools/install-go.sh
|
||||
RUN tools/install-bazel.sh
|
||||
|
||||
ENTRYPOINT ["/usr/bin/env", "bash"]
|
||||
|
||||
64
tools/install-bazel.sh
Executable file
64
tools/install-bazel.sh
Executable file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euxo pipefail
|
||||
|
||||
INSTALL_DIR="/usr/local/bin"
|
||||
SUDO=sudo
|
||||
|
||||
preflight () {
|
||||
if [ "$(whoami)" = "root" ]
|
||||
then
|
||||
SUDO=""
|
||||
fi
|
||||
}
|
||||
|
||||
bazel_setup () {
|
||||
local BAZEL_BIN="$(command -v bazel)"
|
||||
local BUILDIFIER_BIN="$(command -v buildifier)"
|
||||
local BAZELISK_VERSION="1.16.0"
|
||||
|
||||
if [ "$(uname -s)" != "Linux" ]
|
||||
then
|
||||
echo '[!] godeb is only supported on Linux.' > /dev/stderr
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$(uname -m)" in
|
||||
amd64) ARCH="amd64" ;;
|
||||
arm64) ARCH="arm64" ;;
|
||||
x86_64) ARCH="amd64" ;;
|
||||
*)
|
||||
echo "[!] $(uname -m) is an unsupported architecture." > /dev/stderr
|
||||
echo '[!] supported architectures: amd64, arm64' > /dev/stderr
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
local BAZELISK_URL="https://github.com/bazelbuild/bazelisk/releases/download/v${BAZELISK_VERSION}/bazelisk-linux-${ARCH}"
|
||||
local BAZELISK_DBIN="${BAZELISK_URL##*/}"
|
||||
|
||||
if [ ! -x "${INSTALL_DIR}/bazelisk" ]
|
||||
then
|
||||
pushd /tmp
|
||||
curl -LO "${BAZELISK_URL}"
|
||||
chmod +x "${BAZELISK_DBIN}"
|
||||
$SUDO mv "${BAZELISK_DBIN}" "${INSTALL_DIR}/bazelisk"
|
||||
popd
|
||||
fi
|
||||
|
||||
local BUILDTOOLS_REPO="https://github.com/bazelbuild/buildtools"
|
||||
|
||||
if [ ! -x "${INSTALL_DIR}/buildifier" ]
|
||||
then
|
||||
pushd /tmp
|
||||
git clone "${BUILDTOOLS_REPO}"
|
||||
pushd "${BUILDTOOLS_REPO##*/}"
|
||||
bazelisk build //buildifier
|
||||
sudo mv bazel-bin/buildifier/buildifier_/buildifier "${INSTALL_DIR}/buildifier"
|
||||
popd
|
||||
popd
|
||||
fi
|
||||
}
|
||||
|
||||
preflight
|
||||
bazel_setup
|
||||
21
tools/install-dependencies.sh
Executable file
21
tools/install-dependencies.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euxo pipefail
|
||||
|
||||
INSTALL_DIR="/usr/local/bin"
|
||||
SUDO=sudo
|
||||
|
||||
preflight () {
|
||||
if [ "$(whoami)" = "root" ]
|
||||
then
|
||||
SUDO=""
|
||||
fi
|
||||
}
|
||||
|
||||
apt_packages () {
|
||||
$SUDO apt-get update
|
||||
$SUDO apt-get -y install git bash curl sudo build-essential
|
||||
}
|
||||
|
||||
preflight
|
||||
apt_packages
|
||||
7
tools/install.sh
Executable file
7
tools/install.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euxo pipefail
|
||||
|
||||
./install-dependencies.sh
|
||||
./install-go.sh
|
||||
./install-bazel.sh
|
||||
Reference in New Issue
Block a user