Skip to content

Commit 3ab3b5d

Browse files
author
Bruno Castro
committed
Add better docker tooling
1 parent 2b8eef1 commit 3ab3b5d

File tree

14 files changed

+174
-36
lines changed

14 files changed

+174
-36
lines changed

dbin/build

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
USER_ID=$(id -u) GROUP_ID=$(id -g) docker-compose build dev

dbin/chimg

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
PARENT_DIR="$(cd "$(dirname "$0")" && cd .. && pwd)"
4+
5+
cp "$PARENT_DIR/docker/Dockerfile.dev" "$PARENT_DIR/docker/Dockerfile.dev.bkp"
6+
7+
echo -e "\nRUN $*" >> "$PARENT_DIR/docker/Dockerfile.dev"
8+
9+
if USER_ID=$(id -u) GROUP_ID=$(id -g) docker-compose build dev; then
10+
rm -f "$PARENT_DIR/docker/Dockerfile.dev.bkp"
11+
else
12+
mv "$PARENT_DIR/docker/Dockerfile.dev.bkp" "$PARENT_DIR/docker/Dockerfile.dev"
13+
fi

dbin/dispose

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
docker-compose down -v

dbin/local-env

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
DIR="$(cd "$(dirname "$0")" && pwd)"
4+
5+
export PATH="$PATH:$DIR"

dbin/mkalias

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
DIR="$(cd "$(dirname "$0")" && pwd)"
4+
5+
if [[ $1 == --root ]] ; then
6+
runner="\$DIR/run --root"
7+
name=$2
8+
shift 2
9+
else
10+
runner="\$DIR/run"
11+
name=$1
12+
shift 1
13+
fi
14+
15+
cat >"$DIR/$name" <<EOL
16+
#!/bin/bash
17+
18+
DIR="\$(cd "\$(dirname "\$0")" && pwd)"
19+
20+
. "$runner" $@ "\$@"
21+
EOL
22+
23+
chmod +x "$DIR/$name"

dbin/mvroot

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
PARENT_DIR="$(cd "$(dirname "$0")" && cd .. && pwd)"
4+
5+
TARGET_DIR="$1"
6+
7+
mv "$PARENT_DIR/README.md" "$PARENT_DIR/INSTRUCTIONS.md" 2>/dev/null
8+
9+
(shopt -s dotglob; mv "$PARENT_DIR/$TARGET_DIR"/* "$PARENT_DIR")
10+
11+
rm -r "${PARENT_DIR:?}/$TARGET_DIR"

dbin/npm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
DIR="$(cd "$(dirname "$0")" && pwd)"
4+
5+
. "$DIR/run" npm "$@"

dbin/npx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
DIR="$(cd "$(dirname "$0")" && pwd)"
4+
5+
. "$DIR/run" npx "$@"

dbin/run

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
user=""
4+
5+
if [[ $1 == --root ]] ; then
6+
user="--user root"
7+
shift 1
8+
fi
9+
10+
if docker-compose ps -a | grep -E -i -q 'app(\s*)running'; then
11+
USER_ID=$(id -u) GROUP_ID=$(id -g) docker-compose --profile dev exec $user dev "$@"
12+
else
13+
USER_ID=$(id -u) GROUP_ID=$(id -g) docker-compose --profile dev run --rm $user --service-ports dev "$@"
14+
fi

dbin/shell

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
DIR="$(cd "$(dirname "$0")" && pwd)"
4+
5+
if [[ $1 == --root ]] ; then
6+
shift
7+
. "$DIR/run" --root /bin/ash "$@"
8+
else
9+
. "$DIR/run" /bin/ash "$@"
10+
fi

0 commit comments

Comments
 (0)