diff --git a/Vagrantfile b/Vagrantfile index 7a182f8f6..7fab7e224 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -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' diff --git a/scripts/release/Dockerfile b/scripts/release/Dockerfile new file mode 100644 index 000000000..035004e73 --- /dev/null +++ b/scripts/release/Dockerfile @@ -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 diff --git a/scripts/release/Makefile.linux b/scripts/release/Makefile.linux new file mode 100644 index 000000000..70f7bd65e --- /dev/null +++ b/scripts/release/Makefile.linux @@ -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 ' \ + --message "Generate files for $(NOMAD_VERSION) release" + + @echo "======>> building release artifacts" + $(MAKE) $(RELEASE_TARGET) diff --git a/scripts/release/docker-build-all b/scripts/release/docker-build-all new file mode 100755 index 000000000..f1be5aca5 --- /dev/null +++ b/scripts/release/docker-build-all @@ -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 diff --git a/scripts/vagrant-linux-priv-config.sh b/scripts/vagrant-linux-priv-config.sh index 7c8b38c52..b2400c5c0 100755 --- a/scripts/vagrant-linux-priv-config.sh +++ b/scripts/vagrant-linux-priv-config.sh @@ -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) diff --git a/scripts/vagrant-linux-priv-dev.sh b/scripts/vagrant-linux-priv-dev.sh new file mode 100755 index 000000000..2b22a36a6 --- /dev/null +++ b/scripts/vagrant-linux-priv-dev.sh @@ -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 diff --git a/scripts/vagrant-linux-priv-docker.sh b/scripts/vagrant-linux-priv-docker.sh new file mode 100755 index 000000000..22a9c5717 --- /dev/null +++ b/scripts/vagrant-linux-priv-docker.sh @@ -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