Skip to content

Commit

Permalink
BUILD/MEDIUM: goreleaser: Build apk, rpm and deb packages
Browse files Browse the repository at this point in the history
Use nFPM to build APK (Alpine), RPM (RHEL/CentOS/Rocky/Alma etc.) and DEB
(Ubuntu/Debian) packages. Additionally generate automatic Changelog and
provide a sample config for binary archives and packages.
  • Loading branch information
dkorunic authored and mjuraga committed Jul 26, 2023
1 parent b4e4c45 commit 12f632e
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 4 deletions.
9 changes: 5 additions & 4 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ before:
hooks:
- go mod download
- go mod tidy
- make clean
- mkdir build/
builds:
-
id: my-build
main: ./cmd/dataplaneapi/main.go
binary: ./build/dataplaneapi
main: ./cmd/dataplaneapi
binary: dataplaneapi
ldflags:
- -s -w -X main.GitRepo={{.GitURL}} -X main.GitTag={{.Tag}} -X main.GitCommit={{.ShortCommit}} -X main.GitDirty= -X main.BuildTime={{.Date}}
env:
Expand All @@ -25,6 +23,9 @@ builds:
- arm64
- ppc64le
- s390x
changelog:
sort: asc
use: git
archives:
-
id: my-archive
Expand Down
15 changes: 15 additions & 0 deletions assets/packages/dataplaneapi.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=HAProxy Data Plane API
After=syslog.target network-online.target

[Service]
Environment="PIDFILE=/run/dataplaneapi.pid"
EnvironmentFile=/etc/default/dataplaneapi
ExecStart=/usr/sbin/dataplaneapi $SYSD_OPTIONS
ExecReload=/bin/kill -s SIGUSR1 $MAINPID
Type=simple
PIDFile=
GuessMainPID=1

[Install]
WantedBy=multi-user.target
28 changes: 28 additions & 0 deletions assets/packages/dataplaneapi.yml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
dataplaneapi:
host: 0.0.0.0
port: 5555
userlist:
userlist: dataplaneapi
resources:
maps_dir: /etc/haproxy/maps
ssl_certs_dir: /etc/haproxy/ssl
general_storage_dir: /etc/haproxy/general
spoe_dir: /etc/haproxy/spoe
transaction:
transaction_dir: /var/lib/dataplaneapi/transactions
backups_number: 10
backups_dir: /var/lib/dataplaneapi/backups
haproxy:
config_file: /etc/haproxy/haproxy.cfg
haproxy_bin: /usr/sbin/haproxy
reload:
reload_delay: 5
service_name: haproxy
reload_strategy: systemd
log_targets:
- log_to: file
log_file: /var/log/dataplaneapi.log
log_level: info
log_types:
- access
- app
3 changes: 3 additions & 0 deletions assets/packages/default
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Options for dataplaneapi

SYSD_OPTIONS='-f /etc/dataplaneapi/dataplaneapi.yml'
9 changes: 9 additions & 0 deletions assets/packages/logrotate
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/var/log/dataplaneapi.log {
missingok
compress
notifempty
copytruncate
daily
rotate 7
create 0640 root root
}
4 changes: 4 additions & 0 deletions assets/packages/post-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

systemctl --system daemon-reload || true
systemctl enable dataplaneapi || true
3 changes: 3 additions & 0 deletions assets/packages/post-uninstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

systemctl --system daemon-reload || true
4 changes: 4 additions & 0 deletions assets/packages/pre-uninstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

systemctl stop dataplaneapi || true
systemctl disable dataplaneapi || true

0 comments on commit 12f632e

Please sign in to comment.