Add a Docker release scripts

Also tease out some dev and docker bits from Vagrant scripts to ease
sharing with Docker script
This commit is contained in:
Mahmood Ali 2019-03-14 07:45:49 -04:00
parent d61e73afb8
commit 67b6758bed
7 changed files with 146 additions and 16 deletions

8
Vagrantfile vendored
View File

@ -125,6 +125,14 @@ def configureLinuxProvisioners(vmCfg)
privileged: true,
path: './scripts/vagrant-linux-priv-config.sh'
vmCfg.vm.provision "shell",
privileged: true,
path: './scripts/vagrant-linux-priv-dev.sh'
vmCfg.vm.provision "shell",
privileged: true,
path: './scripts/vagrant-linux-priv-docker.sh'
vmCfg.vm.provision "shell",
privileged: true,
path: './scripts/vagrant-linux-priv-consul.sh'

View File

@ -0,0 +1,44 @@
# Dockerfile for building nomad binaries
# that mimics Vagrant environment as far as required
# for building the scripts and running provision scripts
FROM ubuntu:16.04
RUN apt-get update; apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
git \
sudo \
tree \
unzip \
wget
RUN useradd --create-home vagrant \
&& echo 'vagrant ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers
# install priv packages
ADD ./scripts/vagrant-linux-priv-config.sh /tmp/scripts/vagrant-linux-priv-config.sh
RUN /tmp/scripts/vagrant-linux-priv-config.sh
ADD ./scripts/vagrant-linux-priv-go.sh /tmp/scripts/vagrant-linux-priv-go.sh
RUN /tmp/scripts/vagrant-linux-priv-go.sh
ADD ./scripts/vagrant-linux-priv-protoc.sh /tmp/scripts/vagrant-linux-priv-protoc.sh
RUN /tmp/scripts/vagrant-linux-priv-protoc.sh
USER vagrant
ADD ./scripts/vagrant-linux-unpriv-ui.sh /tmp/scripts/vagrant-linux-unpriv-ui.sh
RUN /tmp/scripts/vagrant-linux-unpriv-ui.sh
# Update PATH with GO bin, yarn, and node
ENV GOPATH="/opt/gopath" \
PATH="/home/vagrant/bin:/opt/gopath/bin:/home/vagrant/.yarn/bin:/home/vagrant/.config/yarn/global/node_modules/.bin:$PATH"
RUN mkdir -p /opt/gopath/src/github.com/hashicorp/nomad
RUN mkdir -p /home/vagrant/bin \
&& git config --global user.email "nomad@hashicorp.com" \
&& git config --global user.name "Nomad Release Bot"
COPY --chown=vagrant:vagrant ./scripts/release/docker-build-all /home/vagrant/bin/docker-build-all

View File

@ -0,0 +1,29 @@
NOMAD_VERSION = 0.9.0-dev
NOMAD_MAIN_VERSION := $(shell echo $(NOMAD_VERSION) | cut -d- -f1)
NOMAD_PRERELEASE_VERSION := $(shell echo $(NOMAD_VERSION) | cut -d- -f2-)
update_version:
@echo "updating version to $(NOMAD_MAIN_VERSION)-$(NOMAD_PRERELEASE_VERSION)"
@sed -i.bak -e 's|\(Version * = *"\)[^"]*|\1$(NOMAD_MAIN_VERSION)|g' version/version.go
@sed -i.bak -e 's|\(VersionPrerelease * = *"\)[^"]*|\1$(NOMAD_PRERELEASE_VERSION)|g' version/version.go
@rm -rf version/version.go.bak
PRERELEASE_TARGET = prerelease
RELEASE_TARGET = release
build_releases:
@echo "======>> installing dependencies"
$(MAKE) bootstrap
@echo "======>> pre-releasing"
$(MAKE) $(PRERELEASE_TARGET)
@echo "======>> committing generated files"
git add -A .
git commit --author 'Nomad Release bot <nomad@hashicorp.com>' \
--message "Generate files for $(NOMAD_VERSION) release"
@echo "======>> building release artifacts"
$(MAKE) $(RELEASE_TARGET)

View File

@ -0,0 +1,20 @@
#!/usr/bin/env bash
. ~/.nvm/nvm.sh
set -e
set -x
cp -r /tmp/nomad-git /opt/gopath/src/github.com/hashicorp/nomad/.git
cd /opt/gopath/src/github.com/hashicorp/nomad
git checkout .
make -f ./scripts/release/Makefile.linux \
"NOMAD_VERSION=${NOMAD_VERSION}" \
"PRERELEASE_TARGET=${PRERELEASE_TARGET}" \
"RELEASE_TARGET=${RELEASE_TARGET}" \
update_version build_releases
cp -r /opt/gopath/src/github.com/hashicorp/nomad \
/tmp/artifacts/repo

View File

@ -9,15 +9,6 @@ apt-get install -y software-properties-common
# Add i386 architecture (for libraries)
dpkg --add-architecture i386
# Add the Docker repository
apt-key adv \
--keyserver hkp://p80.pool.sks-keyservers.net:80 \
--recv-keys 9DC858229FC7DD38854AE2D88D81803C0EBFCD88
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
# Update with i386, Go and Docker
apt-get update
@ -35,7 +26,6 @@ apt-get install -y \
apt-get install -y \
curl \
default-jre \
docker-ce \
htop \
jq \
qemu \
@ -60,12 +50,6 @@ apt-get install -y \
# Ensure everything is up to date
apt-get upgrade -y
# Restart Docker in case it got upgraded
systemctl restart docker.service
# Ensure Docker can be used by vagrant user
usermod -aG docker vagrant
# Set hostname -> IP to make advertisement work as expected
ip=$(ip route get 1 | awk '{print $NF; exit}')
hostname=$(hostname)

View File

@ -0,0 +1,24 @@
#!/usr/bin/env bash
# Install Development utilities
apt-get install -y \
curl \
default-jre \
htop \
jq \
qemu \
silversearcher-ag \
tree \
unzip \
vim
# Set hostname -> IP to make advertisement work as expected
ip=$(ip route get 1 | awk '{print $NF; exit}')
hostname=$(hostname)
sed -i -e "s/.*nomad.*/${ip} ${hostname}/" /etc/hosts
# Ensure we cd into the working directory on login
if ! grep "cd /opt/gopath/src/github.com/hashicorp/nomad" /home/vagrant/.profile ; then
echo 'cd /opt/gopath/src/github.com/hashicorp/nomad' >> /home/vagrant/.profile
fi

View File

@ -0,0 +1,21 @@
#!/usr/bin/env bash
# Add the Docker repository
apt-key adv \
--keyserver hkp://p80.pool.sks-keyservers.net:80 \
--recv-keys 9DC858229FC7DD38854AE2D88D81803C0EBFCD88
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
# Update with i386, Go and Docker
apt-get update
apt-get install -y docker-ce
# Restart Docker in case it got upgraded
systemctl restart docker.service
# Ensure Docker can be used by vagrant user
usermod -aG docker vagrant