File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,18 +5,17 @@ ENV bashunit_version='0.23.0'
55ENV bashunit_hash='7043c1818016f330ee12671a233f89906f0d373f3b2aa231a8c40123be5a222b'
66
77# bashunit installation dependencies
8- RUN apt-get update; apt-get install -y curl perl git; rm -rf /var/lib/apt/lists/*
8+ RUN apt-get update; apt-get install -y curl perl git docker.io sudo ; rm -rf /var/lib/apt/lists/*
99
1010RUN mkdir -p $bashunit_dir
1111RUN curl -o /tmp/install.sh https://bashunit.typeddevs.com/install.sh
1212RUN bash /tmp/install.sh $bashunit_dir $bashunit_version; ln -s $bashunit_dir/bashunit /usr/bin/bashunit; chmod +x $bashunit_dir/bashunit
1313
1414# verify the sha256sum for bashunit 0.14.0
15- RUN DIR="$bashunit_dir" ; KNOWN_HASH="$bashunit_hash" ; FILE="$DIR/bashunit" ; [ "$(shasum -a 256 " $FILE" | awk '{ print $1 }')" = "$KNOWN_HASH" ] && echo -e "✓ \0 33[1mbashunit\0 33[0m verified." || { echo -e "✗ \0 33[1mbashunit\0 33[0m corrupt" ; rm "$FILE" ; }
15+ RUN DIR="$bashunit_dir" ; KNOWN_HASH="$bashunit_hash" ; FILE="$DIR/bashunit" ; [ "$(shasum -a 256 " $FILE" | awk '{ print $1 }')" = "$KNOWN_HASH" ] && echo -e "✓ \0 33[1mbashunit\0 33[0m verified." || { echo -e "✗ \0 33[1mbashunit\0 33[0m corrupt" ; rm "$FILE" ; } ; bashunit --version;
1616
17- RUN bashunit --version
18-
19- RUN groupadd -g 1000 dev && useradd -m -u 1000 -g dev dev
17+ RUN groupadd -g 1000 dev && useradd -m -u 1000 -g dev dev && \
18+ echo "dev ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/dev && chmod 0440 /etc/sudoers.d/dev
2019
2120WORKDIR /home/dev/shell-dev-tools
2221
@@ -30,5 +29,5 @@ RUN git config --global init.defaultBranch master && \
3029 git config --global user.email "shell@dev.tools" && \
3130 git config --global user.name "dev"
3231
33- ENTRYPOINT ["/bin/bash " ]
32+ ENTRYPOINT ["/home/dev/shell-dev-tools/docker-entrypoint.sh " ]
3433
Original file line number Diff line number Diff line change 11# shell dev tools
22
3- ![ tests status] ( https://github.com/devloberto/shell-dev-tools/actions/workflows/test.yml/badge.svg )
3+ [ ![ tests status] ( https://github.com/devloberto/shell-dev-tools/actions/workflows/test.yml/badge.svg )] ( https://github.com/devloberto/shell-dev-tools/actions/workflows/test.yml )
44
55handy tools for developers using bash or zsh
66
Original file line number Diff line number Diff line change @@ -8,5 +8,5 @@ services:
88 - shell-dev-tools:debian-trixie
99 volumes :
1010 - $PWD:/home/dev/shell-dev-tools
11- entrypoint : tail -f /dev/null
11+ - /var/run/docker.sock:/var/run/docker.sock:ro
1212
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # setup docker group to match the host's docker socket group
4+ DOCKER_GID=$( stat -c ' %g' /var/run/docker.sock)
5+ if ! getent group docker > /dev/null; then
6+ sudo groupadd -g " $DOCKER_GID " docker
7+ else
8+ sudo groupmod -g " $DOCKER_GID " docker
9+ fi
10+ sudo usermod -aG docker dev # and add 'dev' user to docker group
11+
12+ # keep the container running
13+ tail -f /dev/null
Original file line number Diff line number Diff line change 11SOURCE=" ${BASH_SOURCE[0]:- ${(% ):-% x} } " # bash and zsh compatability
22SCRIPT_DIR=" $( realpath -e -- " $( dirname -- " $SOURCE " ) " ) "
33
4+ source " $SCRIPT_DIR /src/docker.sh"
45source " $SCRIPT_DIR /src/git_delete_all_branches_but_default.sh"
56source " $SCRIPT_DIR /src/strcnt.sh"
67source " $SCRIPT_DIR /src/unix.sh"
Original file line number Diff line number Diff line change 1+ dockerll () {
2+ docker ps -a --format " table {{ .Names }}\t{{ .Status }}\t{{ .Networks }}\t{{ .Ports }}"
3+ }
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ function set_up() {
4+ ROOT_DIR=" $( dirname " ${BASH_SOURCE[0]} " ) /.."
5+ source " $ROOT_DIR /src/docker.sh"
6+ }
7+
8+ test_dockerll () {
9+ local output=$( dockerll)
10+
11+ # output header
12+ local first_line=$( echo " $output " | head -n 1)
13+ assert_contains " NAMES " " $first_line "
14+ assert_contains " STATUS " " $first_line "
15+ assert_contains " NETWORKS " " $first_line "
16+ assert_contains " PORTS" " $first_line "
17+
18+ # output shell-dev-tools container
19+ local second_line=$( echo " $output " | sed -n ' 2p' ) # @TODO: what if it's not the 2. line?
20+ assert_contains " shell-dev-tools " " $second_line "
21+ assert_matches " Up [0-9]+ minutes " " $second_line "
22+ assert_contains " shell-dev-tools_default" " $second_line "
23+ }
You can’t perform that action at this time.
0 commit comments