Skip to content
Snippets Groups Projects
Commit b2bdc42a authored by Stéphane Veyret's avatar Stéphane Veyret Committed by Stéphane Veyret
Browse files

Change Vagrant with docker for building Debian

parent 61574b18
No related branches found
No related tags found
2 merge requests!12331.6,!1227Change Vagrant with docker for building Debian
......@@ -23,6 +23,7 @@ vagrant/duniter
*.tar.gz
*.log
*.exe
/release/arch/debian/duniter-source
# vscode
.vscode
......
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "https://s3.eu-central-1.amazonaws.com/duniter/vagrant/duniter_trusty64.box"
config.vm.provision :shell, path: "bootstrap.sh"
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
#vb.gui = true
# Customize the amount of memory on the VM:
vb.memory = "2048"
end
#
# View the documentation for the provider you are using for more
# information on available options.
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
# such as FTP and Heroku are also available. See the documentation at
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
# config.push.define "atlas" do |push|
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
# end
# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
# config.vm.provision "shell", inline: <<-SHELL
# apt-get update
# apt-get install -y apache2
# SHELL
end
#!/bin/bash
# Yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
# System tools
apt-get update
apt-get install --yes git curl build-essential yarn python-minimal zip
# User installation
sudo su vagrant -c "bash /vagrant/user-bootstrap.sh"
#!/bin/bash
# NVM
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
# Prepare
......@@ -13,6 +12,7 @@ NW_VERSION=0.24.4
NW_RELEASE="v${NW_VERSION}"
NW="nwjs-${NW_RELEASE}-linux-x64"
NW_GZ="${NW}.tar.gz"
DUNITER_SRC=/dunidata/duniter-source
nvm install ${NVER}
nvm use ${NVER}
......@@ -23,55 +23,37 @@ ROOT=`pwd`
DOWNLOADS="$ROOT/downloads"
RELEASES="$ROOT/releases"
mkdir -p "$DOWNLOADS"
mkdir -p "$DOWNLOADS" || exit 1
# -----------
# Clean sources + releases
# Clean up
# -----------
rm -rf "$DOWNLOADS/duniter"
rm -rf "$RELEASES"
rm -rf /vagrant/*.deb
rm -rf /vagrant/*.tar.gz
rm -rf /dunidata/*.deb
rm -rf /dunidata/*.tar.gz
# -----------
# Downloads
# Sources and downloads
# -----------
cd "$DOWNLOADS"
if [ ! -d "$DOWNLOADS/duniter" ]; then
mv /vagrant/duniter-source duniter
cd duniter
git checkout "v${DUNITER_TAG}"
cd ..
fi
DUNITER_DEB_VER=" $DUNITER_TAG"
DUNITER_TAG="v$DUNITER_TAG"
if [ ! -f "$DOWNLOADS/$NW_GZ" ]; then
wget https://dl.nwjs.io/${NW_RELEASE}/${NW_GZ}
tar xvzf ${NW_GZ}
fi
cd "${DUNITER_SRC}"
git checkout "${DUNITER_TAG}" || exit 1
if [ ! -f "$DOWNLOADS/node-${NVER}-linux-x64.tar.gz" ]; then
cd "$DOWNLOADS"
curl -O https://dl.nwjs.io/${NW_RELEASE}/${NW_GZ} || exit 1
tar xzf ${NW_GZ} || exit 1
# Download Node.js and package it with the sources
wget http://nodejs.org/dist/${NVER}/node-${NVER}-linux-x64.tar.gz
tar xzf node-${NVER}-linux-x64.tar.gz
fi
curl -O http://nodejs.org/dist/${NVER}/node-${NVER}-linux-x64.tar.gz || exit 1
tar xzf node-${NVER}-linux-x64.tar.gz || exit 1
# -----------
# Releases
# -----------
rm -rf "$RELEASES"
mkdir -p "$RELEASES"
cp -r "$DOWNLOADS/duniter" "$RELEASES/duniter"
cd "$RELEASES"
# NPM build
cp -r duniter _npm
mkdir -p "$RELEASES" || exit 1
cp -r "${DUNITER_SRC}" "$RELEASES/duniter" || exit 1
# Releases builds
cd ${RELEASES}/duniter
......@@ -84,41 +66,48 @@ rm -Rf .git
[[ $? -eq 0 ]] && npm install duniter-ui@1.6.x
[[ $? -eq 0 ]] && npm prune --production
cp -r "$RELEASES/duniter" "$RELEASES/desktop_"
cp -r "$RELEASES/duniter" "$RELEASES/server_"
[[ $? -eq 0 ]] || exit 1
cp -r "$RELEASES/duniter" "$RELEASES/desktop_" || exit 1
cp -r "$RELEASES/duniter" "$RELEASES/server_" || exit 1
# -------------------------------------------------
# Build Desktop version (Nw.js is embedded)
# -------------------------------------------------
cd "$RELEASES/desktop_"
echo "$NW_RELEASE"
cd "$RELEASES/desktop_/node_modules/wotb"
# FIX: bug of nw.js, we need to patch first.
# TODO: remove this patch once a correct version of Nw.js is out (NodeJS 8 or 9 if the above modules are compliant)
cp /vagrant/0.24.4_common.gypi ~/.nw-gyp/0.24.4/common.gypi
cd "$RELEASES/desktop_/node_modules/wotb"
node-pre-gyp --runtime=node-webkit --target=$NW_VERSION configure \
|| echo "This failure is expected"
cp /dunidata/0.24.4_common.gypi ~/.nw-gyp/0.24.4/common.gypi || exit 1
cd "$RELEASES/desktop_/node_modules/wotb"
#yarn --build-from-source
node-pre-gyp --runtime=node-webkit --target=$NW_VERSION configure
node-pre-gyp --runtime=node-webkit --target=$NW_VERSION build
cp lib/binding/Release/node-webkit-$NW_RELEASE-linux-x64/wotb.node lib/binding/Release/node-v$ADDON_VERSION-linux-x64/wotb.node
node-pre-gyp --runtime=node-webkit --target=$NW_VERSION configure || exit 1
node-pre-gyp --runtime=node-webkit --target=$NW_VERSION build || exit 1
cp lib/binding/Release/node-webkit-$NW_RELEASE-linux-x64/wotb.node \
lib/binding/Release/node-v$ADDON_VERSION-linux-x64/wotb.node || exit 1
cd "$RELEASES/desktop_/node_modules/naclb"
#npm install --build-from-source
node-pre-gyp --runtime=node-webkit --target=$NW_VERSION configure
node-pre-gyp --runtime=node-webkit --target=$NW_VERSION build
cp lib/binding/Release/node-webkit-$NW_RELEASE-linux-x64/naclb.node lib/binding/Release/node-v$ADDON_VERSION-linux-x64/naclb.node
node-pre-gyp --runtime=node-webkit --target=$NW_VERSION configure || exit 1
node-pre-gyp --runtime=node-webkit --target=$NW_VERSION build || exit 1
cp lib/binding/Release/node-webkit-$NW_RELEASE-linux-x64/naclb.node \
lib/binding/Release/node-v$ADDON_VERSION-linux-x64/naclb.node || exit 1
cd "$RELEASES/desktop_/node_modules/scryptb"
#npm install --build-from-source
node-pre-gyp --runtime=node-webkit --target=$NW_VERSION configure
node-pre-gyp --runtime=node-webkit --target=$NW_VERSION build
cp lib/binding/Release/node-webkit-$NW_RELEASE-linux-x64/scryptb.node lib/binding/Release/node-v$ADDON_VERSION-linux-x64/scryptb.node
node-pre-gyp --runtime=node-webkit --target=$NW_VERSION configure || exit 1
node-pre-gyp --runtime=node-webkit --target=$NW_VERSION build || exit 1
cp lib/binding/Release/node-webkit-$NW_RELEASE-linux-x64/scryptb.node \
lib/binding/Release/node-v$ADDON_VERSION-linux-x64/scryptb.node || exit 1
cd "$RELEASES/desktop_/node_modules/sqlite3"
#npm install --build-from-source
node-pre-gyp --runtime=node-webkit --target=$NW_VERSION configure
node-pre-gyp --runtime=node-webkit --target=$NW_VERSION build
cp lib/binding/node-webkit-$NW_RELEASE-linux-x64/node_sqlite3.node lib/binding/node-v$ADDON_VERSION-linux-x64/node_sqlite3.node
node-pre-gyp --runtime=node-webkit --target=$NW_VERSION configure || exit 1
node-pre-gyp --runtime=node-webkit --target=$NW_VERSION build || exit 1
cp lib/binding/node-webkit-$NW_RELEASE-linux-x64/node_sqlite3.node \
lib/binding/node-v$ADDON_VERSION-linux-x64/node_sqlite3.node || exit 1
# Unused binaries
cd "$RELEASES/desktop_/"
......@@ -128,39 +117,39 @@ rm -rf node_modules/sqlite3/build
#rm -rf node_modules/scryptb/build
## Install Nw.js
mkdir -p "$RELEASES/desktop_release"
mkdir -p "$RELEASES/desktop_release" || exit 1
# -------------------------------------------------
# Build Desktop version .tar.gz
# -------------------------------------------------
cp -r $DOWNLOADS/${NW}/* "$RELEASES/desktop_release/"
cp -r $DOWNLOADS/${NW}/* "$RELEASES/desktop_release/" || exit 1
# Embed Node.js with Nw.js to make Duniter modules installable
cp -r ${DOWNLOADS}/node-${NVER}-linux-x64/lib "$RELEASES/desktop_release/"
cp -r ${DOWNLOADS}/node-${NVER}-linux-x64/include "$RELEASES/desktop_release/"
cp -r ${DOWNLOADS}/node-${NVER}-linux-x64/bin "$RELEASES/desktop_release/"
cp -r ${DOWNLOADS}/node-${NVER}-linux-x64/lib "$RELEASES/desktop_release/" || exit 1
cp -r ${DOWNLOADS}/node-${NVER}-linux-x64/include "$RELEASES/desktop_release/" || exit 1
cp -r ${DOWNLOADS}/node-${NVER}-linux-x64/bin "$RELEASES/desktop_release/" || exit 1
# Add some specific files for GUI
cp ${RELEASES}/desktop_/gui/* "$RELEASES/desktop_release/"
cp ${RELEASES}/desktop_/gui/* "$RELEASES/desktop_release/" || exit 1
# Add Duniter sources
cp -R $RELEASES/desktop_/* "$RELEASES/desktop_release/"
cp -R $RELEASES/desktop_/* "$RELEASES/desktop_release/" || exit 1
## Insert Nw specific fields while they do not exist (1.3.3)
sed -i "s/\"main\": \"index.js\",/\"main\": \"index.html\",/" "$RELEASES/desktop_release/package.json"
sed -i "s/\"main\": \"index.js\",/\"main\": \"index.html\",/" "$RELEASES/desktop_release/package.json" || exit 1
# Add links for Node.js + NPM
cd "$RELEASES/desktop_release/bin"
ln -s ../lib/node_modules/npm/bin/npm-cli.js ./npm -f
ln -s ../lib/node_modules/npm/bin/npm-cli.js ./npm -f || exit 1
cd ..
ln -s ./bin/node node -f
ln -s ./bin/npm npm -f
ln -s ./bin/node node -f || exit 1
ln -s ./bin/npm npm -f || exit 1
#sed -i "s/\"node-main\": \"\.\.\/sources\/bin\/duniter\",/\"node-main\": \".\/bin\/duniter\",/" "$RELEASES/desktop_release/package.json"
# Create a copy for TGZ binary
cp -R "$RELEASES/desktop_release" "$RELEASES/desktop_release_tgz"
cp -R "$RELEASES/desktop_release" "$RELEASES/desktop_release_tgz" || exit 1
#cd "$RELEASES/desktop_release_tgz/"
#rm -rf node_modules/sqlite3/lib/binding/node-webkit-$NW_RELEASE-linux-x64
#rm -rf node_modules/wotb/lib/binding/Release/node-webkit-$NW_RELEASE-linux-x64
#rm -rf node_modules/naclb/lib/binding/Release/node-webkit-$NW_RELEASE-linux-x64
#rm -rf node_modules/scryptb/lib/binding/Release/node-webkit-$NW_RELEASE-linux-x64
cd "$RELEASES/desktop_release_tgz"
tar czf /vagrant/duniter-desktop-${DUNITER_TAG}-linux-x64.tar.gz * --exclude ".git" --exclude "coverage" --exclude "test"
tar czf /duniter/duniter-desktop-${DUNITER_TAG}-linux-x64.tar.gz * --exclude "coverage" --exclude "test" || exit 1
# -------------------------------------------------
# Build Desktop version .deb
......@@ -168,11 +157,11 @@ tar czf /vagrant/duniter-desktop-${DUNITER_TAG}-linux-x64.tar.gz * --exclude ".g
# Create .deb tree + package it
#cp -r "$RELEASES/desktop_release/release/arch/debian/package" "$RELEASES/duniter-x64"
cp -r "/vagrant/package" "$RELEASES/duniter-x64"
mkdir -p "$RELEASES/duniter-x64/opt/duniter/"
cp -r "/dunidata/package" "$RELEASES/duniter-x64" || exit 1
mkdir -p "$RELEASES/duniter-x64/opt/duniter/" || exit 1
chmod 755 ${RELEASES}/duniter-x64/DEBIAN/post*
chmod 755 ${RELEASES}/duniter-x64/DEBIAN/pre*
sed -i "s/Version:.*/Version:$DUNITER_DEB_VER/g" ${RELEASES}/duniter-x64/DEBIAN/control
sed -i "s/Version:.*/Version:$DUNITER_DEB_VER/g" ${RELEASES}/duniter-x64/DEBIAN/control || exit 1
cd ${RELEASES}/desktop_release/
#rm -rf node_modules/sqlite3/lib/binding/node-webkit-$NW_RELEASE-linux-x64
#rm -rf node_modules/wotb/lib/binding/Release/node-webkit-$NW_RELEASE-linux-x64
......@@ -182,12 +171,12 @@ cd ${RELEASES}/desktop_release/
#rm -rf node_modules/wotb/lib/binding/Release/node-v$ADDON_VERSION-linux-x64
#rm -rf node_modules/naclb/lib/binding/Release/node-v$ADDON_VERSION-linux-x64
#rm -rf node_modules/scryptb/lib/binding/Release/node-v$ADDON_VERSION-linux-x64
zip -qr ${RELEASES}/duniter-x64/opt/duniter/duniter-desktop.nw *
zip -qr ${RELEASES}/duniter-x64/opt/duniter/duniter-desktop.nw * || exit 1
sed -i "s/Package: .*/Package: duniter-desktop/g" ${RELEASES}/duniter-x64/DEBIAN/control
sed -i "s/Package: .*/Package: duniter-desktop/g" ${RELEASES}/duniter-x64/DEBIAN/control || exit 1
cd ${RELEASES}/
fakeroot dpkg-deb --build duniter-x64
mv duniter-x64.deb /vagrant/duniter-desktop-${DUNITER_TAG}-linux-x64.deb
fakeroot dpkg-deb --build duniter-x64 || exit 1
mv duniter-x64.deb /duniter/duniter-desktop-${DUNITER_TAG}-linux-x64.deb || exit 1
# -------------------------------------------------
# Build Server version (Node.js is embedded, not Nw.js)
......@@ -195,16 +184,16 @@ mv duniter-x64.deb /vagrant/duniter-desktop-${DUNITER_TAG}-linux-x64.deb
cd ${RELEASES}
rm -rf duniter-server-x64
cp -r duniter-x64 duniter-server-x64
cp -r duniter-x64 duniter-server-x64 || exit 1
# Remove Nw.js
rm -rf duniter-server-x64/opt/duniter/duniter-desktop.nw*
cd ${RELEASES}/server_
cp -r ${DOWNLOADS}/node-${NVER}-linux-x64 node
zip -qr ${RELEASES}/duniter-server-x64/opt/duniter/duniter-desktop.nw *
cp -r ${DOWNLOADS}/node-${NVER}-linux-x64 node || exit 1
zip -qr ${RELEASES}/duniter-server-x64/opt/duniter/duniter-desktop.nw * || exit 1
cd ${RELEASES}
sed -i "s/Package: .*/Package: duniter/g" ${RELEASES}/duniter-server-x64/DEBIAN/control
sed -i "s/Package: .*/Package: duniter/g" ${RELEASES}/duniter-server-x64/DEBIAN/control || exit 1
rm -rf ${RELEASES}/duniter-server-x64/usr
fakeroot dpkg-deb --build duniter-server-x64
mv duniter-server-x64.deb /vagrant/duniter-server-${DUNITER_TAG}-linux-x64.deb
fakeroot dpkg-deb --build duniter-server-x64 || exit 1
mv duniter-server-x64.deb /duniter/duniter-server-${DUNITER_TAG}-linux-x64.deb || exit 1
#!/bin/bash
# NVM
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
# Node.js
nvm install 6
# node-pre-gyp
npm install -g nw-gyp node-pre-gyp
......@@ -56,16 +56,13 @@ make)
cd ..
fi
[[ $? -eq 0 ]] && echo ">> Starting Vagrant Ubuntu VM..."
[[ $? -eq 0 ]] && vagrant up
[[ $? -eq 0 ]] && echo ">> VM: building Duniter..."
[[ $? -eq 0 ]] && vagrant ssh -- "bash -s ${TAG}" < ./build-deb.sh
docker pull duniter/release-builder:17.12.1
docker run --rm -it -v ${PWD}:/dunidata duniter/release-builder:17.12.1 ${TAG}
if [ ! $? -eq 0 ]; then
echo ">> Something went wrong. Stopping build."
else
echo ">> Build success. Shutting the VM down."
fi
vagrant halt
echo ">> VM closed."
else
echo "Debian binaries already built. Ready for upload."
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment