#!/bin/bash function build { echo "building container..." docker build -t ignite-cli -f - > /dev/null . << EOF FROM golang:1.23.0 WORKDIR /apps RUN apt update && \ apt-get install -y \ build-essential \ ca-certificates \ unzip \ curl \ vim \ git RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && \ apt-get install -y nodejs RUN echo '\n\ alias a="cd /apps" \n\ alias s="cd /src " \n\ alias c="(cd && GLOBIGNORE='.bashrc:.cache:.config:.npm:.profile'; rm -rf *) && rm -rf /apps/*" \n\ alias i="(s && go install ./...)"' > ~/.bashrc EOF } function run { docker kill ignite-cli > /dev/null 2>&1 docker rm ignite-cli > /dev/null 2>&1 docker run \ --name ignite-cli \ -d \ -p 26657:26657 \ -p 1317:1317 \ -v $PWD:/src \ -v $PWD/apps:/apps \ ignite-cli /bin/bash -c "trap : TERM INT; sleep infinity & wait" \ > /dev/null } function attach { is_running=$(docker ps -q -f status=running -f name=^/ignite-cli$) if [[ -z $is_running ]]; then run; fi docker exec -ti ignite-cli /bin/bash } case "$1" in # build the development container. build) build ;; # restart the development container. reset) run ;; # scratch builds the container, resets existing and attaches to it. scratch) build run attach ;; # attach to development container but start if not already running. *) attach ;; esac # in container commands: # i install Ignite CLI # s cd into Ignite CLI's source code # a cd into apps dir # c cleanup previous app installations