Skip to content

Commit

Permalink
add upx as part of building step to shrink the size of binary files (
Browse files Browse the repository at this point in the history
  • Loading branch information
tigerinus authored Dec 29, 2022
1 parent b4ddeed commit 56eeb0e
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
run: |
sudo apt update
sudo apt-get --no-install-recommends --yes install \
libc6-dev-amd64-cross \
upx libc6-dev-amd64-cross \
gcc-aarch64-linux-gnu libc6-dev-arm64-cross \
gcc-arm-linux-gnueabihf libc6-dev-armhf-cross
-
Expand Down
39 changes: 30 additions & 9 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ before:
builds:
- id: casaos-gateway-amd64
binary: build/sysroot/usr/bin/casaos-gateway
hooks:
post:
- upx --best --lzma -v --no-progress "{{ .Path }}"
env:
- CC=x86_64-linux-gnu-gcc
ldflags:
- -X main.commit={{.Commit}}
- -X main.date={{.Date}}
- -s
- -w
- -extldflags "-static"
Expand All @@ -22,14 +27,16 @@ builds:
- linux
goarch:
- amd64
hooks:
post:
- find build/sysroot -type f | xargs -L 1 realpath --relative-to=build/sysroot > build/sysroot.manifest
- id: casaos-gateway-arm64
binary: build/sysroot/usr/bin/casaos-gateway
hooks:
post:
- upx --best --lzma -v --no-progress "{{ .Path }}"
env:
- CC=aarch64-linux-gnu-gcc
ldflags:
- -X main.commit={{.Commit}}
- -X main.date={{.Date}}
- -s
- -w
- -extldflags "-static"
Expand All @@ -41,14 +48,16 @@ builds:
- linux
goarch:
- arm64
hooks:
post:
- find build/sysroot -type f | xargs -L 1 realpath --relative-to=build/sysroot > build/sysroot.manifest
- id: casaos-gateway-arm-7
binary: build/sysroot/usr/bin/casaos-gateway
hooks:
post:
- upx --best --lzma -v --no-progress "{{ .Path }}"
env:
- CC=arm-linux-gnueabihf-gcc
ldflags:
- -X main.commit={{.Commit}}
- -X main.date={{.Date}}
- -s
- -w
- -extldflags "-static"
Expand All @@ -62,15 +71,17 @@ builds:
- arm
goarm:
- "7"
hooks:
post:
- find build/sysroot -type f | xargs -L 1 realpath --relative-to=build/sysroot > build/sysroot.manifest
- id: casaos-gateway-migration-tool-amd64
binary: build/sysroot/usr/bin/casaos-gateway-migration-tool
hooks:
post:
- upx --best --lzma -v --no-progress "{{ .Path }}"
main: ./cmd/migration-tool
env:
- CC=x86_64-linux-gnu-gcc
ldflags:
- -X main.commit={{.Commit}}
- -X main.date={{.Date}}
- -s
- -w
- -extldflags "-static"
Expand All @@ -84,10 +95,15 @@ builds:
- amd64
- id: casaos-gateway-migration-tool-arm64
binary: build/sysroot/usr/bin/casaos-gateway-migration-tool
hooks:
post:
- upx --best --lzma -v --no-progress "{{ .Path }}"
main: ./cmd/migration-tool
env:
- CC=aarch64-linux-gnu-gcc
ldflags:
- -X main.commit={{.Commit}}
- -X main.date={{.Date}}
- -s
- -w
- -extldflags "-static"
Expand All @@ -101,10 +117,15 @@ builds:
- arm64
- id: casaos-gateway-migration-tool-arm-7
binary: build/sysroot/usr/bin/casaos-gateway-migration-tool
hooks:
post:
- upx --best --lzma -v --no-progress "{{ .Path }}"
main: ./cmd/migration-tool
env:
- CC=arm-linux-gnueabihf-gcc
ldflags:
- -X main.commit={{.Commit}}
- -X main.date={{.Date}}
- -s
- -w
- -extldflags "-static"
Expand Down
10 changes: 9 additions & 1 deletion cmd/migration-tool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ const (
//go:embedded ../../build/sysroot/etc/casaos/gateway.ini.sample
//var _gatewayINISample string

var _logger *Logger
var (
commit = "private build"
date = "private build"

_logger *Logger
)

// var _status *version.GlobalMigrationStatus

Expand All @@ -36,6 +41,9 @@ func main() {
os.Exit(0)
}

println("git commit:", commit)
println("build date:", date)

_logger = NewLogger()

if os.Getuid() != 0 {
Expand Down
2 changes: 1 addition & 1 deletion common/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package common

const Version = "0.3.8"
const Version = "0.4.1"
54 changes: 27 additions & 27 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,58 @@ module github.com/IceWhaleTech/CasaOS-Gateway
go 1.19

require (
github.com/IceWhaleTech/CasaOS-Common v0.3.7-5
github.com/IceWhaleTech/CasaOS-Common v0.4.0
github.com/gin-contrib/gzip v0.0.6
github.com/gin-gonic/gin v1.8.1
github.com/spf13/viper v1.12.0
go.uber.org/fx v1.17.1
github.com/gin-gonic/gin v1.8.2
github.com/spf13/viper v1.14.0
go.uber.org/fx v1.18.2
gotest.tools v2.2.0+incompatible
)

require (
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/godbus/dbus/v5 v5.0.4 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
)

require (
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/go-playground/validator/v10 v10.10.0 // indirect
github.com/goccy/go-json v0.9.7 // indirect
github.com/golang-jwt/jwt/v4 v4.4.2 // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/go-playground/validator/v10 v10.11.1 // indirect
github.com/goccy/go-json v0.10.0 // indirect
github.com/golang-jwt/jwt/v4 v4.4.3 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/afero v1.9.3 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.3.0 // indirect
github.com/ugorji/go/codec v1.2.7 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/dig v1.14.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.21.0
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/protobuf v1.28.0 // indirect
github.com/subosito/gotenv v1.4.1 // indirect
github.com/ugorji/go/codec v1.2.8 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/dig v1.15.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
go.uber.org/zap v1.24.0
golang.org/x/crypto v0.4.0 // indirect
golang.org/x/net v0.4.0 // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.3.0
gotest.tools/v3 v3.4.0
)
Loading

0 comments on commit 56eeb0e

Please sign in to comment.