Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build GitHub Releases with tinygo #665

Open
coolaj86 opened this issue Dec 14, 2023 · 2 comments
Open

Build GitHub Releases with tinygo #665

coolaj86 opened this issue Dec 14, 2023 · 2 comments

Comments

@coolaj86
Copy link

coolaj86 commented Dec 14, 2023

Those file sizes are dang huge for something that just reads text files in lexicographical order, connects to a DB, and execs them.

Especially for a tool that is needed as part of ci/cd.

Would you consider building with tinygo?

(it drops the advanced garbage collector for a much simpler one, but otherwise implements the same API)

Example:

GOOS=linux GOARCH=arm64 \
    tinygo build -short -no-debug \
    -o hello-v1.0.0-linux-arm64
@coolaj86 coolaj86 changed the title Build with tinygo Build GitHub Releases with tinygo Dec 14, 2023
@mfridman
Copy link
Collaborator

mfridman commented Dec 14, 2023

I experimented with tinygo ~yr ago, and ran into weird build issues. Didn't bother pursuing this in favor of building features, bug fixes and improving docs.

Most of the bloat in the published binaries comes from the SQL drivers, since the pre-built goose binary aims to support all of them.

However, you can reduce the resulting binary size by using the exclusive build tags:

https://pressly.github.io/goose/installation/#building-from-source (a bit out-of-date, will update)

binary only, no drivers

go build \    
    -ldflags="-s -w" \
    -tags='no_postgres no_sqlite3 no_clickhouse no_mssql no_mysql no_vertica no_ydb' \
    -o goose ./cmd/goose

3.6M    ./goose

sqlite driver only (modernc.org/sqlite)

# target only sqlite
go build \                       
    -ldflags="-s -w" \
    -tags='no_postgres no_clickhouse no_mssql no_mysql no_vertica no_ydb' \
    -o goose ./cmd/goose

7.2M    ./goose

postgres driver only (github.com/jackc/pgx/v5/stdlib)

go build \                   
    -ldflags="-s -w" \
    -tags='no_sqlite3 no_clickhouse no_mssql no_mysql no_vertica no_ydb' \
    -o goose ./cmd/goose

10M    ./goose

full binary, all drivers

go build -o goose ./cmd/goose

41M    ./goose

@mfridman
Copy link
Collaborator

Fwiw I'd love to reduce the resulting binary size, which will inevitably grow over time as more drivers are added.

I acknowledge it's not great, but I also don't have a good answer for this at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants