92 lines
1.8 KiB
Bash
92 lines
1.8 KiB
Bash
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
trap cleanup ERR SIGTERM
|
|
|
|
cleanup() {
|
|
# docker kill vault_build
|
|
echo "end"
|
|
}
|
|
|
|
BUILDDIR='/tmp/vault_build'
|
|
OUT_DIR='/tmp/vault/'
|
|
ARCH_DOCKER_REPO='https://scm.f1x.online/mirrors/archlinux-docker.git'
|
|
VAULT_REPO='https://scm.f1x.online/mirrors/vault.git'
|
|
|
|
mkdir -vp "${BUILDDIR}" "${OUT_DIR}"
|
|
|
|
pushd "${BUILDDIR}"
|
|
|
|
### fetch & docker-build build container code
|
|
test -d arch_docker_repo || git clone --depth=1 "${ARCH_DOCKER_REPO}" arch_docker_repo
|
|
cd arch_docker_repo
|
|
#git fetch && git pull
|
|
make image-base
|
|
|
|
cat << EOF_BUILD_BASE | docker build -t bb:local -
|
|
FROM archlinux/archlinux:base
|
|
RUN pacman --noconfirm -Syu \
|
|
base-devel \
|
|
git \
|
|
go \
|
|
gox \
|
|
make \
|
|
nodejs-lts-erbium \
|
|
npm \
|
|
python2 \
|
|
yarn
|
|
RUN mkdir -p /src/github.com/hashicorp
|
|
RUN cd /src/github.com/hashicorp && \
|
|
git clone --depth=1 ${VAULT_REPO}
|
|
EOF_BUILD_BASE
|
|
|
|
### run build container
|
|
test -n "$(docker ps -aq -f name=vault_build)" || \
|
|
docker run \
|
|
-d \
|
|
--rm \
|
|
--name vault_build \
|
|
-v /etc/pacman.d/mirrorlist:/etc/pacman.d/mirrorlist:ro \
|
|
bb:local \
|
|
sleep infinity
|
|
|
|
### setup build env
|
|
# docker exec vault_build \
|
|
# pacman --noconfirm -Syu \
|
|
# base-devel \
|
|
# git \
|
|
# go \
|
|
# gox \
|
|
# make \
|
|
# npm \
|
|
# python2 \
|
|
# yarn
|
|
# docker exec vault_build \
|
|
# mkdir -p /src/github.com/hashicorp
|
|
# docker exec -w /src/github.com/hashicorp vault_build \
|
|
# git clone --depth=1 "${VAULT_REPO}"
|
|
|
|
### build
|
|
docker exec \
|
|
-e XC_OSARCH=linux/amd64 \
|
|
-w /src/github.com/hashicorp/vault vault_build \
|
|
make bootstrap
|
|
docker exec \
|
|
-e GOPATH=/root/go \
|
|
-e XC_OSARCH=linux/amd64 \
|
|
-w /src/github.com/hashicorp/vault vault_build \
|
|
make static-dist bin
|
|
|
|
### copy binary
|
|
docker cp \
|
|
vault_build:/src/github.com/hashicorp/vault/bin/vault - > "${OUT_DIR}/vault"
|
|
stat "${OUT_DIR}/vault"
|
|
|
|
### cleanup
|
|
popd
|
|
docker kill vault_build
|
|
rm -rd "${BUILDDIR}"
|
|
|
|
exit 0
|