Skip to content

Commit f728d8d

Browse files
feat(container): Allow non-default branch selection
1 parent 2e84cb3 commit f728d8d

File tree

6 files changed

+42
-5
lines changed

6 files changed

+42
-5
lines changed

packages/documentation/docs/development.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ If you ever want to [rebuild the container from scratch](/reference/Repository S
6464
yarn devcontainer:rebuild
6565
```
6666

67+
### Kittens Game Branch
68+
69+
You can run the development container on another branch of Kittens Game by providing the branch name to the `devcontainer` commands, like so:
70+
71+
```shell
72+
yarn devcontainer:run dev/alpha
73+
```
74+
6775
## Development without Container
6876

6977
To develop without containers, you can build a development version of the userscript with full debugging information.

packages/kitten-game/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
FROM node:18-buster
22

3+
ARG BRANCH=master
4+
35
EXPOSE 8080
46

57
RUN git clone https://bitbucket.org/bloodrizer/kitten-game.git && \
68
cd kitten-game && \
9+
git checkout $BRANCH && \
710
yarn install
811

912
# Copy the script that injects kitten-scientists.inject.js into index.html and execute it.

packages/kitten-game/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
},
1616
"main": "Dockerfile",
1717
"scripts": {
18-
"devcontainer:build": "docker build --tag kitten-game .",
19-
"devcontainer:rebuild": "docker build --no-cache --tag kitten-game .",
18+
"devcontainer:build": "bash ./scripts/build-development-container.sh",
19+
"devcontainer:rebuild": "bash ./scripts/rebuild-development-container.sh",
2020
"devcontainer:run": "bash ./scripts/run-development-container.sh"
2121
}
2222
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit
4+
5+
BRANCH=${1:-master}
6+
7+
echo "Building development container on $BRANCH branch..."
8+
export DOCKER_SCAN_SUGGEST=false
9+
docker build \
10+
--build-arg BRANCH="$BRANCH" \
11+
--tag kitten-game .
12+
echo "Done."
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit
4+
5+
BRANCH=${1:-master}
6+
7+
echo "Re-Building development container on $BRANCH branch..."
8+
export DOCKER_SCAN_SUGGEST=false
9+
docker build \
10+
--build-arg BRANCH="$BRANCH" \
11+
--no-cache \
12+
--tag kitten-game .
13+
echo "Done."

packages/kitten-game/scripts/run-development-container.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
set -o errexit
44

55
BASEDIR=$(dirname "$(readlink -f "$0")")
6+
BRANCH=${1:-master}
67

78
yarn userscript:build
8-
yarn devcontainer:build
9+
yarn devcontainer:build "$BRANCH"
910

1011
echo "Removing previous container..."
11-
docker stop kitten-game || true
12-
docker rm kitten-game || true
12+
docker stop kitten-game > /dev/null || true
13+
docker rm kitten-game > /dev/null || true
1314
echo "Previous container removed or non-existent."
1415
echo ""
1516

0 commit comments

Comments
 (0)