Skip to content

Commit 37d542e

Browse files
committed
Made repos private, updated dockerfiles
1 parent 0e88471 commit 37d542e

7 files changed

Lines changed: 35 additions & 10 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ pip install -e '.[dev]'
1111
pre-commit install
1212
```
1313

14+
Make sure you have `GITHUB_TOKEN` (w/ access permissions for this organization) set in a `.env` file
15+
1416
### Usage
1517

1618
To run `n` rounds of 2+ models competing against one another on a game, run the following:

codeclash/games/abstract.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ def build_image(self):
6060

6161
# Build the Docker image
6262
result = subprocess.run(
63-
f"docker build -t {self.image_name} -f docker/{self.name}.Dockerfile .",
63+
(
64+
"export $(cat .env | xargs);"
65+
f"docker build --build-arg GITHUB_TOKEN=$GITHUB_TOKEN -t {self.image_name} -f docker/{self.name}.Dockerfile ."
66+
),
6467
shell=True,
6568
capture_output=True,
6669
text=True,
@@ -71,7 +74,7 @@ def build_image(self):
7174
self.logger.error(
7275
f"❌ Failed to build Docker image: {result.stderr}\n{result.stdout}{result.stderr}"
7376
)
74-
raise
77+
raise RuntimeError(f"Failed to build Docker image: {result.stderr}")
7578

7679
def end(self, cleanup: bool = False):
7780
self.logger.info(Counter([x[1] for x in self.scoreboard]))

docker/BattleCode.Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
55
build-essential git curl && \
66
rm -rf /var/lib/apt/lists/*
77

8-
RUN git clone https://github.com/emagedoc/BattleCode.git /testbed
9-
8+
ARG GITHUB_TOKEN
9+
RUN git clone https://${GITHUB_TOKEN}@github.com/emagedoc/BattleCode.git /testbed \
10+
&& cd /testbed \
11+
&& git remote set-url origin https://github.com/emagedoc/BattleCode.git \
12+
&& unset GITHUB_TOKEN
1013
WORKDIR /testbed
1114

12-
RUN python run.py update
15+
RUN python run.py update

docker/BattleSnake.Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ RUN ARCH=$(dpkg --print-architecture) && \
1818
tar -C /usr/local -xzf /tmp/go.tar.gz && \
1919
rm /tmp/go.tar.gz
2020

21-
RUN git clone https://github.com/emagedoc/BattleSnake.git /testbed
21+
# Inject GitHub token for private repo access
22+
ARG GITHUB_TOKEN
23+
RUN git clone https://${GITHUB_TOKEN}@github.com/emagedoc/BattleSnake.git /testbed \
24+
&& cd /testbed \
25+
&& git remote set-url origin https://github.com/emagedoc/BattleSnake.git \
26+
&& unset GITHUB_TOKEN
2227

2328
WORKDIR /testbed
2429

docker/CoreWar.Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ RUN apt-get update \
55
curl ca-certificates wget git build-essential jq curl locales \
66
&& rm -rf /var/lib/apt/lists/*
77

8-
RUN git clone https://github.com/emagedoc/CoreWar.git /testbed
8+
ARG GITHUB_TOKEN
9+
RUN git clone https://${GITHUB_TOKEN}@github.com/emagedoc/CoreWar.git /testbed \
10+
&& cd /testbed \
11+
&& git remote set-url origin https://github.com/emagedoc/CoreWar.git \
12+
&& unset GITHUB_TOKEN
913

1014
WORKDIR /testbed
1115

docker/RoboCode.Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ ant \
1111
unzip \
1212
&& rm -rf /var/lib/apt/lists/*
1313

14-
RUN git clone https://github.com/emagedoc/RoboCode.git testbed
14+
ARG GITHUB_TOKEN
15+
RUN git clone https://${GITHUB_TOKEN}@github.com/emagedoc/RoboCode.git /testbed \
16+
&& cd /testbed \
17+
&& git remote set-url origin https://github.com/emagedoc/RoboCode.git \
18+
&& unset GITHUB_TOKEN
1519

16-
WORKDIR /testbed
20+
WORKDIR /testbed

docker/RobotRumble.Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ RUN apt-get update \
99
python3-pip python-is-python3 wget git build-essential jq curl locales \
1010
&& rm -rf /var/lib/apt/lists/*
1111

12-
RUN git clone https://github.com/emagedoc/RobotRumble.git /testbed
12+
ARG GITHUB_TOKEN
13+
RUN git clone https://${GITHUB_TOKEN}@github.com/emagedoc/RobotRumble.git /testbed \
14+
&& cd /testbed \
15+
&& git remote set-url origin https://github.com/emagedoc/RobotRumble.git \
16+
&& unset GITHUB_TOKEN
1317

1418
WORKDIR /testbed

0 commit comments

Comments
 (0)