Browse Source

CI vs RPM build (#317)

pull/1/head
Evgeny Smyshlyaev 6 years ago committed by rozetko
parent
commit
5263a9c4bb
  1. 2
      .gitignore
  2. 8
      .travis.yml
  3. 27
      Makefile
  4. 11
      build/rpmbuild/Dockerfile
  5. 3
      build/rpmbuild/Makefile
  6. 94
      build/rpmbuild/hastic-server.spec

2
.gitignore vendored

@ -1,5 +1,5 @@
data
dist
dist/**/*.rpm
config.json
.env

8
.travis.yml

@ -1,3 +1,7 @@
services:
- docker
matrix:
include:
- language: node_js
@ -20,5 +24,9 @@ matrix:
apt-utils gnupg curl make g++ git
script:
- python -m unittest discover
script:
- make
notifications:
email: false

27
Makefile

@ -0,0 +1,27 @@
.PHONY: rpm deb
all: rpm deb
rpm_node8:
docker run --rm -it -v `pwd`/server:/root/rpmbuild/server \
-v `pwd`/analytics:/root/rpmbuild/analytics \
-v `pwd`/.git:/root/rpmbuild/.git \
-v `pwd`/build/rpmbuild:/root/rpmbuild/rpm \
-v `pwd`/dist/RPMS_8:/root/rpmbuild/RPMS \
-e "NODE_VERSION=v8.0.0" \
-e "RPM_NODE_VERSION=8" \
-e "HASTIC_RELEASE_VERSION=`cat server/package.json| jq -r .version | sed 's/-/_/g'`" \
amper43/hastic-rpmbuilder rpmbuild -bb rpm/hastic-server.spec
rpm_node6:
docker run --rm -v `pwd`/server:/root/rpmbuild/server \
-v `pwd`/analytics:/root/rpmbuild/analytics \
-v `pwd`/.git:/root/rpmbuild/.git \
-v `pwd`/build/rpmbuild:/root/rpmbuild/rpm \
-v `pwd`/dist/RPMS_6:/root/rpmbuild/RPMS \
-e "NODE_VERSION=v6.14.0" \
-e "RPM_NODE_VERSION=6" \
-e "HASTIC_RELEASE_VERSION=`cat server/package.json| jq -r .version | sed 's/-/_/g'`" \
amper43/hastic-rpmbuilder rpmbuild -bb rpm/hastic-server.spec
rpm: rpm_node8 rpm_node6

11
build/rpmbuild/Dockerfile

@ -0,0 +1,11 @@
FROM rpmbuild/centos7
USER root
WORKDIR /root/rpmbuild
RUN yum -y install https://centos7.iuscommunity.org/ius-release.rpm epel-release
RUN yum -y install python36 python36-devel python36-setuptools gcc-c++ make \
&& easy_install-3.6 pip \
&& pip3.6 install -U pip setuptools pyinstaller \
&& curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash -

3
build/rpmbuild/Makefile

@ -0,0 +1,3 @@
all:
docker build -t amper43/hastic-rpmbuilder .
docker push amper43/hastic-rpmbuilder

94
build/rpmbuild/hastic-server.spec

@ -0,0 +1,94 @@
%define name hastic-server
%define version %{getenv:HASTIC_RELEASE_VERSION}_node%{getenv:RPM_NODE_VERSION}
%define release 0
%define buildroot /root/rpmbuild/BUILDROOT
%define builddir /root/rpmbuild/BUILD
Name: %{name}
Version: %{version}
Release: %{release}
Summary: hastic-server
Group: Installation Script
License: Apache-2.0
URL: hastic.io
BuildRoot: %{buildroot}
AutoReqProv: no
AutoReq: no
BuildArch: noarch
%description
REST server for managing data for analytics
%prep
rm -rf %{builddir}/*
mkdir -p %{builddir}
mkdir -p %{builddir}/.git/refs/heads
cp -r %{builddir}/../.git/HEAD %{builddir}/.git
cp -r %{builddir}/../.git/refs/heads %{builddir}/.git/refs
cp -r %{builddir}/../server %{builddir}/
cp -r %{builddir}/../analytics %{builddir}/
set +x
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install %{getenv:NODE_VERSION}
set -x
%build
pushd analytics
mkdir -p dist/server
touch dist/server/server
save=$RPM_BUILD_ROOT
unset RPM_BUILD_ROOT
pip3 install -U pip setuptools pyinstaller
pip3 install -r requirements.txt
pyinstaller -y --additional-hooks-dir=pyinstaller_hooks --paths=analytics/ bin/server
export RPM_BUILD_ROOT=$save
popd
pushd server
set +x
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm use %{getenv:NODE_VERSION}
set -x
npm install
npm run build
popd
%install
mkdir -p %{buildroot}/usr/lib/hastic-server/server/dist
mkdir -p %{buildroot}/usr/lib/hastic-server/.git/refs/heads
mkdir -p %{buildroot}/usr/lib/hastic-server/analytics/dist/server
cp -r server/dist %{buildroot}/usr/lib/hastic-server/server/
cp -r .git/HEAD %{buildroot}/usr/lib/hastic-server/.git
cp -r .git/refs/heads %{buildroot}/usr/lib/hastic-server/.git/refs
cp -r analytics/dist/server %{buildroot}/usr/lib/hastic-server/analytics/dist/
%post
mkdir -p /etc/hastic-server/
if [ ! -f /etc/hastic-server/config.json ]; then
echo '{}' > /etc/hastic-server/config.json
fi
ln -s /etc/hastic-server/config.json /usr/lib/hastic-server/config.json
mkdir -p /var/hastic-server/
ln -s /usr/lib/hastic-server/data /var/hastic-server/data
echo 'node /usr/lib/hastic-server/server/dist/server' > /usr/bin/hastic-server
chmod +x /usr/bin/hastic-server
%clean
rm -rf %{buildroot}
%files
%attr(755, root, root) /usr/lib/hastic-server/analytics/dist/server/server
%defattr(644, root, root, 755)
/usr/lib/hastic-server
%preun
rm /usr/bin/hastic-server
Loading…
Cancel
Save