mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
Debian packaging (#116)
* initial commit of deb packaging * Incorporated feedback from @valyala: - Put data directory under /var/lib - More beef in systemd file - Packaging for arm64 - Package all target which builds and packages both amd64 and arm64 * Remove PIDFile from systemd unit, useless * per PR feedback, move debian specific files into deb subdirectory Updates #107 .
This commit is contained in:
parent
ea07cf68ba
commit
8c3629a892
10 changed files with 150 additions and 0 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -9,3 +9,5 @@
|
|||
/victoria-metrics-data
|
||||
/vmstorage-data
|
||||
/vmselect-cache
|
||||
/package/temp-deb-*
|
||||
/package/*.deb
|
||||
|
|
|
@ -25,3 +25,18 @@ victoria-metrics-arm:
|
|||
|
||||
victoria-metrics-arm64:
|
||||
CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOARCH=arm64 GO111MODULE=on go build -mod=vendor -ldflags "$(GO_BUILDINFO)" -o bin/victoria-metrics-arm64 ./app/victoria-metrics
|
||||
|
||||
### Packaging for Debian - amd64
|
||||
victoria-metrics-package-deb: victoria-metrics
|
||||
echo "GO_BUILDINFO:" "$(GO_BUILDINFO)"
|
||||
echo "PWD:" "$(PWD)"
|
||||
./package/package_deb.sh amd64
|
||||
|
||||
### Packaging for Debian - arm64
|
||||
victoria-metrics-package-deb-arm64: victoria-metrics-arm64
|
||||
./package/package_deb.sh arm64
|
||||
|
||||
victoria-metrics-package-deb-all: \
|
||||
victoria-metrics-package-deb \
|
||||
victoria-metrics-package-deb-arm64
|
||||
|
||||
|
|
1
package/VAR_BUILD
Normal file
1
package/VAR_BUILD
Normal file
|
@ -0,0 +1 @@
|
|||
1
|
1
package/VAR_VERSION
Normal file
1
package/VAR_VERSION
Normal file
|
@ -0,0 +1 @@
|
|||
1.7.0
|
0
package/deb/conffile
Normal file
0
package/deb/conffile
Normal file
7
package/deb/control
Normal file
7
package/deb/control
Normal file
|
@ -0,0 +1,7 @@
|
|||
Package: victoria-metrics
|
||||
Maintainer: Aliaksandr Valialkin
|
||||
Depends: libc6 (>= 2.7-1)
|
||||
Section: net
|
||||
Priority: optional
|
||||
Homepage: https://github.com/VictoriaMetrics/VictoriaMetrics
|
||||
Description: VictoriaMetrics is fast, cost-effective and scalable time series database. It can be used as a long-term remote storage for Prometheus.
|
5
package/deb/postinst
Normal file
5
package/deb/postinst
Normal file
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# Reload systemd unit
|
||||
systemctl daemon-reload
|
0
package/deb/postrm
Normal file
0
package/deb/postrm
Normal file
103
package/package_deb.sh
Executable file
103
package/package_deb.sh
Executable file
|
@ -0,0 +1,103 @@
|
|||
#!/bin/bash
|
||||
|
||||
ARCH="amd64"
|
||||
if [[ $# -ge 1 ]]
|
||||
then
|
||||
ARCH="$1"
|
||||
fi
|
||||
|
||||
# Map to Debian architecture
|
||||
if [[ "$ARCH" == "amd64" ]]; then
|
||||
DEB_ARCH=amd64
|
||||
EXENAME_SRC="victoria-metrics"
|
||||
elif [[ "$ARCH" == "arm64" ]]; then
|
||||
DEB_ARCH=arm64
|
||||
EXENAME_SRC="victoria-metrics-arm64"
|
||||
else
|
||||
echo "*** Unknown arch $ARCH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PACKDIR="./package"
|
||||
TEMPDIR="${PACKDIR}/temp-deb-${DEB_ARCH}"
|
||||
EXENAME_DST="victoria-metrics"
|
||||
|
||||
# Pull in version info
|
||||
|
||||
VERSION=`cat ${PACKDIR}/VAR_VERSION | perl -ne 'chomp and print'`
|
||||
BUILD=`cat ${PACKDIR}/VAR_BUILD | perl -ne 'chomp and print'`
|
||||
|
||||
# Create directories
|
||||
|
||||
[[ -d "${TEMPDIR}" ]] && rm -rf "${TEMPDIR}"
|
||||
|
||||
mkdir -p "${TEMPDIR}" && echo "*** Created : ${TEMPDIR}"
|
||||
|
||||
mkdir -p "${TEMPDIR}/usr/sbin/"
|
||||
mkdir -p "${TEMPDIR}/lib/systemd/system/"
|
||||
|
||||
echo "*** Version : ${VERSION}-${BUILD}"
|
||||
echo "*** Arch : ${DEB_ARCH}"
|
||||
|
||||
OUT_DEB="victoria-metrics_${VERSION}-${BUILD}_$DEB_ARCH.deb"
|
||||
|
||||
echo "*** Out .deb : ${OUT_DEB}"
|
||||
|
||||
# Copy the binary
|
||||
|
||||
cp "./bin/${EXENAME_SRC}" "${TEMPDIR}/usr/sbin/${EXENAME_DST}"
|
||||
file "${TEMPDIR}/usr/sbin/${EXENAME_DST}"
|
||||
|
||||
# Copy supporting files
|
||||
|
||||
cp "${PACKDIR}/victoria-metrics.service" "${TEMPDIR}/lib/systemd/system/"
|
||||
|
||||
# Generate debian-binary
|
||||
|
||||
echo "2.0" > "${TEMPDIR}/debian-binary"
|
||||
|
||||
# Generate control
|
||||
|
||||
echo "Version: $VERSION-$BUILD" > "${TEMPDIR}/control"
|
||||
echo "Installed-Size:" `du -sb "${TEMPDIR}" | awk '{print int($1/1024)}'` >> "${TEMPDIR}/control"
|
||||
echo "Architecture: $DEB_ARCH" >> "${TEMPDIR}/control"
|
||||
cat "${PACKDIR}/deb/control" >> "${TEMPDIR}/control"
|
||||
|
||||
# Copy conffile
|
||||
|
||||
cp "${PACKDIR}/deb/conffile" "${TEMPDIR}/conffile"
|
||||
|
||||
# Copy postinst and postrm
|
||||
|
||||
cp "${PACKDIR}/deb/postinst" "${TEMPDIR}/postinst"
|
||||
cp "${PACKDIR}/deb/postrm" "${TEMPDIR}/postrm"
|
||||
|
||||
(
|
||||
# Generate md5 sums
|
||||
|
||||
cd "${TEMPDIR}"
|
||||
|
||||
find ./usr ./lib -type f | while read i ; do
|
||||
md5sum "$i" | sed 's/\.\///g' >> md5sums
|
||||
done
|
||||
|
||||
# Archive control
|
||||
|
||||
chmod 644 control md5sums
|
||||
chmod 755 postrm postinst
|
||||
fakeroot -- tar -c --xz -f ./control.tar.xz ./control ./md5sums ./postinst ./postrm
|
||||
|
||||
# Archive data
|
||||
|
||||
fakeroot -- tar -c --xz -f ./data.tar.xz ./usr ./lib
|
||||
|
||||
# Make final archive
|
||||
|
||||
fakeroot -- ar -cr "${OUT_DEB}" debian-binary control.tar.xz data.tar.xz
|
||||
)
|
||||
|
||||
ls -lh "${TEMPDIR}/${OUT_DEB}"
|
||||
|
||||
cp "${TEMPDIR}/${OUT_DEB}" "${PACKDIR}"
|
||||
|
||||
echo "*** Created : ${PACKDIR}/${OUT_DEB}"
|
16
package/victoria-metrics.service
Normal file
16
package/victoria-metrics.service
Normal file
|
@ -0,0 +1,16 @@
|
|||
[Unit]
|
||||
Description=VictoriaMetrics is a fast, cost-effective and scalable time series database.
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
StartLimitBurst=5
|
||||
StartLimitInterval=0
|
||||
Restart=on-failure
|
||||
RestartSec=1
|
||||
ExecStart=/usr/sbin/victoria-metrics -storageDataPath /var/lib/victoria-metrics -retentionPeriod 12
|
||||
ExecStop=/bin/kill -s SIGTERM $MAINPID
|
||||
LimitNOFILE=32000
|
||||
LimitNPROC=32000
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Loading…
Reference in a new issue