Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also tease out some dev and docker bits from Vagrant scripts to ease sharing with Docker script
- Loading branch information
Mahmood Ali
committed
Mar 17, 2019
1 parent
27924bc
commit d5d6477
Showing
7 changed files
with
146 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |