Skip to content

Commit

Permalink
fix: avoid redirect operator in justfile docker commands (#1804)
Browse files Browse the repository at this point in the history
## Summary
This replaces `sed '...' <<< text` with `echo text | sed '...'` in the
main justfile.

## Background
On Ubuntu, the default shell doesn't recognise the redirect operator
`<<<`, hence the `just` commands `docker-build` and
`docker-build-and-load` both fail on Ubuntu.

## Changes
- Replaced usage of `<<<` by piping `echo` output.

## Testing
Ran the commands on Ubuntu and macOS.

## Changelogs
No updates required.
  • Loading branch information
Fraser999 authored Nov 13, 2024
1 parent bd45898 commit 6708727
Showing 1 changed file with 36 additions and 6 deletions.
42 changes: 36 additions & 6 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,42 @@ default_docker_tag := 'local'
default_repo_name := 'ghcr.io/astriaorg'

# Builds docker image for the crate. Defaults to 'local' tag.
docker-build crate tag=default_docker_tag repo_name=default_repo_name:
docker buildx build --load --build-arg TARGETBINARY={{crate}} -f containerfiles/Dockerfile -t {{repo_name}}/$(sed 's/^[^-]*-//' <<< {{crate}}):{{tag}} .

docker-build-and-load crate tag=default_docker_tag repo_name=default_repo_name:
@just docker-build {{crate}} {{tag}} {{repo_name}}
@just load-image $(sed 's/^[^-]*-//' <<< {{crate}}) {{tag}} {{repo_name}}
# NOTE: `_crate_short_name` is invoked as dependency of this command so that failure to pass a valid
# binary will produce a meaningful error message.
docker-build crate tag=default_docker_tag repo_name=default_repo_name: (_crate_short_name crate "quiet")
#!/usr/bin/env sh
set -eu
short_name=$(just _crate_short_name {{crate}})
set -x
docker buildx build --load --build-arg TARGETBINARY={{crate}} -f containerfiles/Dockerfile -t {{repo_name}}/$short_name:{{tag}} .
# Builds and loads docker image for the crate. Defaults to 'local' tag.
# NOTE: `_crate_short_name` is invoked as dependency of this command so that failure to pass a valid
# binary will produce a meaningful error message.
docker-build-and-load crate tag=default_docker_tag repo_name=default_repo_name: (_crate_short_name crate "quiet")
#!/usr/bin/env sh
set -eu
short_name=$(just _crate_short_name {{crate}})
set -x
just docker-build {{crate}} {{tag}} {{repo_name}}
just load-image $short_name {{tag}} {{repo_name}}
# Maps a crate name to the shortened name used in the docker tag.
# If `quiet` is an empty string the shortened name will be echoed. If `quiet` is a non-empty string,
# the only output will be in the case of an error, where the input `crate` is not a valid one.
_crate_short_name crate quiet="":
#!/usr/bin/env sh
set -eu
case {{crate}} in
astria-bridge-withdrawer) short_name=bridge-withdrawer ;;
astria-cli) short_name=cli ;;
astria-composer) short_name=composer ;;
astria-conductor) short_name=conductor ;;
astria-sequencer) short_name=sequencer ;;
astria-sequencer-relayer) short_name=sequencer-relayer ;;
*) echo "{{crate}} is not a supported binary" && exit 2
esac
[ -z {{quiet}} ] && echo $short_name || true
# Installs the astria rust cli from local codebase
install-cli:
Expand Down

0 comments on commit 6708727

Please sign in to comment.