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 8c96052 commit 856c5ae
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 122 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
30 changes: 30 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ before:
builds:
- id: casaos-user-service-amd64
binary: build/sysroot/usr/bin/casaos-user-service
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 @@ -26,9 +31,14 @@ builds:
- amd64
- id: casaos-user-service-arm64
binary: build/sysroot/usr/bin/casaos-user-service
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 @@ -42,9 +52,14 @@ builds:
- arm64
- id: casaos-user-service-arm-7
binary: build/sysroot/usr/bin/casaos-user-service
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 @@ -60,10 +75,15 @@ builds:
- "7"
- id: casaos-user-service-migration-tool-amd64
binary: build/sysroot/usr/bin/casaos-user-service-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 @@ -77,10 +97,15 @@ builds:
- amd64
- id: casaos-user-service-migration-tool-arm64
binary: build/sysroot/usr/bin/casaos-user-service-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 @@ -94,10 +119,15 @@ builds:
- arm64
- id: casaos-user-service-migration-tool-arm-7
binary: build/sysroot/usr/bin/casaos-user-service-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/user-service.conf.sample
//var _userServiceConfigFileSample 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.4.0"
const Version = "0.4.1"
63 changes: 32 additions & 31 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,41 @@ module github.com/IceWhaleTech/CasaOS-UserService
go 1.19

require (
github.com/IceWhaleTech/CasaOS-Common v0.3.8
github.com/IceWhaleTech/CasaOS-Common v0.4.0
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
github.com/deepmap/oapi-codegen v1.12.2
github.com/getkin/kin-openapi v0.108.0
github.com/deepmap/oapi-codegen v1.12.4
github.com/getkin/kin-openapi v0.112.0
github.com/gin-contrib/gzip v0.0.6
github.com/gin-gonic/gin v1.8.1
github.com/glebarez/sqlite v1.5.0
github.com/labstack/echo/v4 v4.9.1
github.com/gin-gonic/gin v1.8.2
github.com/glebarez/sqlite v1.6.0
github.com/labstack/echo/v4 v4.10.0
github.com/satori/go.uuid v1.2.0
github.com/tidwall/gjson v1.14.1
go.uber.org/zap v1.21.0
golang.org/x/net v0.1.0
github.com/tidwall/gjson v1.14.4
go.uber.org/zap v1.24.0
golang.org/x/net v0.4.0
gopkg.in/ini.v1 v1.67.0
gorm.io/gorm v1.24.0
gorm.io/gorm v1.24.2
)

require (
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
github.com/benbjohnson/clock v1.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/glebarez/go-sqlite v1.19.1 // indirect
github.com/glebarez/go-sqlite v1.20.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/swag v0.21.1 // indirect
github.com/go-openapi/swag v0.22.3 // 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.11.1 // indirect
github.com/goccy/go-json v0.9.11 // indirect
github.com/godbus/dbus/v5 v5.0.4 // indirect
github.com/goccy/go-json v0.10.0 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang-jwt/jwt/v4 v4.4.2 // indirect
github.com/golang-jwt/jwt/v4 v4.4.3 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/invopop/yaml v0.1.0 // indirect
github.com/invopop/yaml v0.2.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/josharian/intern v1.0.0 // indirect
Expand All @@ -45,29 +46,29 @@ require (
github.com/leodido/go-urn v1.2.1 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20220927061507-ef77025ab5aa // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/ugorji/go/codec v1.2.7 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/ugorji/go/codec v1.2.8 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/sys v0.1.0 // indirect
golang.org/x/text v0.4.0 // indirect
golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.4.0 // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/protobuf v1.28.1 // 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
modernc.org/libc v1.19.0 // indirect
modernc.org/libc v1.22.2 // indirect
modernc.org/mathutil v1.5.0 // indirect
modernc.org/memory v1.4.0 // indirect
modernc.org/sqlite v1.19.1 // indirect
modernc.org/memory v1.5.0 // indirect
modernc.org/sqlite v1.20.1 // indirect
)
Loading

0 comments on commit 856c5ae

Please sign in to comment.