Skip to content

rpm, deb and apk packaging example for Golang applications.

License

Notifications You must be signed in to change notification settings

t-katsumura/golang-packaging

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

golang-packaging

This repository is an example of creating .rpm, .deb and .apk packages for Golang applications.

How to use

Setup environments

Install Golang

See https://go.dev/doc/install

Setup fpm with yum

yum update -y && yum install -y make rpm-build rubygems
gem install fpm

Setup fpm with apt

apt update && apt install -y make ruby build-essential
gem install fpm

Setup fpm with apk

apk update && apk add make rpm ruby tar
gem install fpm

Build binary

CGO_ENABLED=0 go build -ldflags="-w -s" ./hello.go

Create packages

Default version and arch are defined in ./Makefile. Overwrite them if necessary.

Packages are output in ./packages/ directory by default.

.rpm using fpm

make fpm-rpm

.deb using fpm

make fpm-deb

.apk using fpm

make fpm-apk

Install and Remove

apt

# Install
apt install ./hello-0.0.0-1.x86_64.deb
# Remove
apt remove --purge hello

rpm

# Install
rpm --nodeps -ivh ./hello-0.0.0-1.x86_64.rpm
# Remove
rpm -e hello-0.0.0-1.x86_64

yum

# Install
yum install ./hello-0.0.0-1.x86_64.rpm
# Remove
yum remove -y hello

apk

# Install
apk add --allow-untrusted hello-0.0.0-1.x86_64.apk
# Remove
apk del hello

References