Skip to content

Commit

Permalink
Pipe in LDFLAGS env var to enable fully static bin (#1053)
Browse files Browse the repository at this point in the history
* Pipe in LDFLAGS env var to enable fully static bin

* Update ibctest/v5. use same uid:gid as previous images
  • Loading branch information
agouin committed Dec 1, 2022
1 parent 109cb65 commit 885c311
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RUN if [ -d "/go/bin/linux_${TARGETARCH}" ]; then mv /go/bin/linux_${TARGETARCH}

# Use minimal busybox from infra-toolkit image for final scratch image
FROM ghcr.io/strangelove-ventures/infra-toolkit:v0.0.6 AS busybox-min
RUN addgroup --gid 1025 -S relayer && adduser --uid 1025 -S relayer -G relayer
RUN addgroup --gid 1000 -S relayer && adduser --uid 100 -S relayer -G relayer

# Use ln and rm from full featured busybox for assembling final image
FROM busybox:1.34.1-musl AS busybox-full
Expand Down Expand Up @@ -64,7 +64,7 @@ COPY --from=busybox-min /etc/ssl/cert.pem /etc/ssl/cert.pem

# Install relayer user
COPY --from=busybox-min /etc/passwd /etc/passwd
COPY --from=busybox-min --chown=1025:1025 /home/relayer /home/relayer
COPY --from=busybox-min --chown=100:1000 /home/relayer /home/relayer

WORKDIR /home/relayer
USER relayer
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ all: lint install
# Build / Install
###############################################################################

LD_FLAGS = -X github.com/cosmos/relayer/v2/cmd.Version=$(VERSION)
ldflags = -X github.com/cosmos/relayer/v2/cmd.Version=$(VERSION)

BUILD_FLAGS := -ldflags '$(LD_FLAGS)'
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))

BUILD_FLAGS := -ldflags '$(ldflags)'

build: go.sum
ifeq ($(OS),Windows_NT)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/avast/retry-go/v4 v4.3.1
github.com/cosmos/cosmos-sdk v0.46.4
github.com/cosmos/cosmos-sdk v0.46.6
github.com/cosmos/ibc-go/v5 v5.1.0
github.com/gogo/protobuf v1.3.3
github.com/google/go-cmp v0.5.9
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ github.com/cosmos/btcutil v1.0.4 h1:n7C2ngKXo7UC9gNyMNLbzqz7Asuf+7Qv4gnX/rOdQ44=
github.com/cosmos/btcutil v1.0.4/go.mod h1:Ffqc8Hn6TJUdDgHBwIZLtrLQC1KdJ9jGJl/TvgUaxbU=
github.com/cosmos/cosmos-proto v1.0.0-alpha7 h1:yqYUOHF2jopwZh4dVQp3xgqwftE5/2hkrwIV6vkUbO0=
github.com/cosmos/cosmos-proto v1.0.0-alpha7/go.mod h1:dosO4pSAbJF8zWCzCoTWP7nNsjcvSUBQmniFxDg5daw=
github.com/cosmos/cosmos-sdk v0.46.4 h1:I4CPfnz7lAPM7cEvvyTxL1h3M/ugbhTNr5ZRcnW8WsU=
github.com/cosmos/cosmos-sdk v0.46.4/go.mod h1:b5usG7aBEEvhaatYCdV6orFbDUsj4BG1V6UtKwNcJeQ=
github.com/cosmos/cosmos-sdk v0.46.6 h1:K9EZsqOZ2jQX3bIQUpn7Hk/YCoaJWRLU56PzvpX8INk=
github.com/cosmos/cosmos-sdk v0.46.6/go.mod h1:JNklMfXo7MhDF1j/jxZCmDyOYyqhVoKB22e8p1ATEqA=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
Expand Down
4 changes: 2 additions & 2 deletions ibctest/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ module github.com/cosmos/relayer/v2/ibctest
go 1.18

require (
github.com/cosmos/cosmos-sdk v0.46.4
github.com/cosmos/cosmos-sdk v0.46.6
github.com/cosmos/ibc-go/v5 v5.1.0
github.com/cosmos/relayer/v2 v2.0.0
github.com/docker/docker v20.10.19+incompatible
github.com/moby/moby v20.10.18+incompatible
github.com/strangelove-ventures/ibctest/v5 v5.0.0-20220922235050-6baac8c666ea
github.com/strangelove-ventures/ibctest/v5 v5.0.0-20221201055938-fa49178c17eb
github.com/stretchr/testify v1.8.1
github.com/tendermint/tendermint v0.34.23
go.uber.org/zap v1.23.0
Expand Down
10 changes: 6 additions & 4 deletions ibctest/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ github.com/cosmos/btcutil v1.0.4 h1:n7C2ngKXo7UC9gNyMNLbzqz7Asuf+7Qv4gnX/rOdQ44=
github.com/cosmos/btcutil v1.0.4/go.mod h1:Ffqc8Hn6TJUdDgHBwIZLtrLQC1KdJ9jGJl/TvgUaxbU=
github.com/cosmos/cosmos-proto v1.0.0-alpha7 h1:yqYUOHF2jopwZh4dVQp3xgqwftE5/2hkrwIV6vkUbO0=
github.com/cosmos/cosmos-proto v1.0.0-alpha7/go.mod h1:dosO4pSAbJF8zWCzCoTWP7nNsjcvSUBQmniFxDg5daw=
github.com/cosmos/cosmos-sdk v0.46.4 h1:I4CPfnz7lAPM7cEvvyTxL1h3M/ugbhTNr5ZRcnW8WsU=
github.com/cosmos/cosmos-sdk v0.46.4/go.mod h1:b5usG7aBEEvhaatYCdV6orFbDUsj4BG1V6UtKwNcJeQ=
github.com/cosmos/cosmos-sdk v0.46.6 h1:K9EZsqOZ2jQX3bIQUpn7Hk/YCoaJWRLU56PzvpX8INk=
github.com/cosmos/cosmos-sdk v0.46.6/go.mod h1:JNklMfXo7MhDF1j/jxZCmDyOYyqhVoKB22e8p1ATEqA=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
Expand Down Expand Up @@ -1084,8 +1084,10 @@ github.com/spf13/viper v1.14.0/go.mod h1:WT//axPky3FdvXHzGw33dNdXXXfFQqmEalje+eg
github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980/go.mod h1:AO3tvPzVZ/ayst6UlUKUv6rcPQInYe3IknH3jYhAKu8=
github.com/strangelove-ventures/go-subkey v1.0.7 h1:cOP/Lajg3uxV/tvspu0m6+0Cu+DJgygkEAbx/s+f35I=
github.com/strangelove-ventures/go-subkey v1.0.7/go.mod h1:E34izOIEm+sZ1YmYawYRquqBQWeZBjVB4pF7bMuhc1c=
github.com/strangelove-ventures/ibctest/v5 v5.0.0-20220922235050-6baac8c666ea h1:jQvO399MoK7+NLigd7Vj7lGsa1Y7LWt8uTtbYGPTyYo=
github.com/strangelove-ventures/ibctest/v5 v5.0.0-20220922235050-6baac8c666ea/go.mod h1:C284t8FhFrldr1BfQHDLsAMMzAWczTgeruePi7M6TmA=
github.com/strangelove-ventures/ibctest/v5 v5.0.0-20221201053013-48511af0d9a6 h1:s6yvcrgGPVeib5cU1elIp3xJaHiHYOoNwcl7akX6oWM=
github.com/strangelove-ventures/ibctest/v5 v5.0.0-20221201053013-48511af0d9a6/go.mod h1:erUg63AnIKlEm/A9tcTqNFH50xiOXvZwEm/dYZ7CQKM=
github.com/strangelove-ventures/ibctest/v5 v5.0.0-20221201055938-fa49178c17eb h1:5ozs6HqJVc0+aFzADexizENc2g7G5+2HKtdBLgW6L2o=
github.com/strangelove-ventures/ibctest/v5 v5.0.0-20221201055938-fa49178c17eb/go.mod h1:erUg63AnIKlEm/A9tcTqNFH50xiOXvZwEm/dYZ7CQKM=
github.com/strangelove-ventures/lens v0.6.0 h1:0cs/14rXCh/RRy4A7l15gHPNTSDsHxbfKC1JA1EdOfs=
github.com/strangelove-ventures/lens v0.6.0/go.mod h1:02mFT/TRg4J76STUzL8Yvne/z5E1ulrjYv5WFhcBXUY=
github.com/stretchr/objx v0.0.0-20180129172003-8a3f7159479f/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down
4 changes: 2 additions & 2 deletions local.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN CGO_ENABLED=1 LDFLAGS='-linkmode external -extldflags "-static"' make instal

# Use minimal busybox from infra-toolkit image for final scratch image
FROM ghcr.io/strangelove-ventures/infra-toolkit:v0.0.6 AS busybox-min
RUN addgroup --gid 1025 -S relayer && adduser --uid 1025 -S relayer -G relayer
RUN addgroup --gid 1000 -S relayer && adduser --uid 100 -S relayer -G relayer

# Use ln and rm from full featured busybox for assembling final image
FROM busybox:1.34.1-musl AS busybox-full
Expand Down Expand Up @@ -48,7 +48,7 @@ COPY --from=busybox-min /etc/ssl/cert.pem /etc/ssl/cert.pem

# Install relayer user
COPY --from=busybox-min /etc/passwd /etc/passwd
COPY --from=busybox-min --chown=1025:1025 /home/relayer /home/relayer
COPY --from=busybox-min --chown=100:1000 /home/relayer /home/relayer

WORKDIR /home/relayer
USER relayer

0 comments on commit 885c311

Please sign in to comment.