WIP
This commit is contained in:
parent
85bb536052
commit
c092f97fa4
53
Dockerfile
53
Dockerfile
@ -1,36 +1,37 @@
|
|||||||
ARG GO_VERSION=alpine
|
FROM archlinux as build
|
||||||
|
|
||||||
FROM golang:${GO_VERSION} as build
|
RUN pacman -Syu --noconfirm \
|
||||||
|
base-devel \
|
||||||
ARG NODE_10_SRC="http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64"
|
|
||||||
|
|
||||||
# NPM_APK=$(wget -qO- "${NODE_10_SRC}" | gawk 'match($0,/^.*href="(npm-10\..*\.apk)".*$/,ary) { print ary[1] }') && \
|
|
||||||
# wget -O nodejs10.apk "${NODE_10_SRC}/${NODE_APK}" && \
|
|
||||||
# wget -O npm10.apk "${NODE_10_SRC}/${NODE_APK}" && \
|
|
||||||
# apk add nodejs10.apk npm10.apk
|
|
||||||
|
|
||||||
RUN \
|
|
||||||
apk update --no-cache && \
|
|
||||||
apk add --no-cache gawk && \
|
|
||||||
NODE_APK=$(wget -qO- "${NODE_10_SRC}" | gawk 'match($0,/^.*href="(nodejs-10\..*\.apk)".*$/,ary) { print ary[1] }') && \
|
|
||||||
wget -O nodejs10.apk "${NODE_10_SRC}/${NODE_APK}" && \
|
|
||||||
apk add nodejs10.apk
|
|
||||||
|
|
||||||
RUN \
|
|
||||||
apk update --no-cache &&\
|
|
||||||
apk add --no-cache \
|
|
||||||
bash \
|
|
||||||
git \
|
git \
|
||||||
make \
|
go \
|
||||||
|
nodejs-lts-erbium \
|
||||||
npm \
|
npm \
|
||||||
yarn && \
|
sudo \
|
||||||
git config --global advice.detachedHead false
|
yarn
|
||||||
|
|
||||||
|
RUN \
|
||||||
|
echo -e 'root ALL=(ALL) ALL\n%wheel ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers && \
|
||||||
|
useradd -m -U -G wheel builduser
|
||||||
|
|
||||||
|
USER builduser
|
||||||
|
|
||||||
|
RUN \
|
||||||
|
cd && \
|
||||||
|
export GOROOT=/usr/lib/go && \
|
||||||
|
export GOPATH=${HOME}/go && \
|
||||||
|
export PATH=${PATH}:${GOROOT}/bin:${GOPATH}/bin && \
|
||||||
|
git config --global advice.detachedHead false && \
|
||||||
|
git clone https://aur.archlinux.org/yay-git.git && \
|
||||||
|
cd yay-git && \
|
||||||
|
makepkg --syncdeps --install --noconfirm && \
|
||||||
|
yay -S --noconfirm \
|
||||||
|
nodejs-ember-cli
|
||||||
|
|
||||||
ARG VAULT_VERSION=
|
ARG VAULT_VERSION=
|
||||||
ARG VAULT_REPO
|
ARG VAULT_REPO
|
||||||
ARG BUILD_PATH=vault
|
ARG BUILD_PATH=vault
|
||||||
|
|
||||||
RUN --mount=type=tmpfs,target=/go/src/ \
|
RUN --mount=type=tmpfs,target=/home/builduser/go/src/ \
|
||||||
echo "selected repo: ${VAULT_REPO}" && \
|
echo "selected repo: ${VAULT_REPO}" && \
|
||||||
if [ -z "${VAULT_VERSION}" ]; then \
|
if [ -z "${VAULT_VERSION}" ]; then \
|
||||||
VAULT_VERSION=$( \
|
VAULT_VERSION=$( \
|
||||||
@ -40,7 +41,7 @@ RUN --mount=type=tmpfs,target=/go/src/ \
|
|||||||
fi && \
|
fi && \
|
||||||
echo "selected vault branch: ${VAULT_VERSION}" && \
|
echo "selected vault branch: ${VAULT_VERSION}" && \
|
||||||
BUILD_PATH=$(echo "${VAULT_REPO}" | sed -E 's/^.*\/\/(.*)\.git/\1/') && \
|
BUILD_PATH=$(echo "${VAULT_REPO}" | sed -E 's/^.*\/\/(.*)\.git/\1/') && \
|
||||||
BUILD_PATH="/go/src/${BUILD_PATH}" && \
|
BUILD_PATH="${GOPATH}/src/${BUILD_PATH}" && \
|
||||||
git clone \
|
git clone \
|
||||||
--branch="${VAULT_VERSION}" \
|
--branch="${VAULT_VERSION}" \
|
||||||
--depth=1 \
|
--depth=1 \
|
||||||
|
91
build.sh
Normal file
91
build.sh
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
#!/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
|
Loading…
Reference in New Issue
Block a user