Skip to content

Commit b7310b5

Browse files
committed
Adding additional configuration polish to the dev container
1 parent 53a864e commit b7310b5

File tree

7 files changed

+151
-2
lines changed

7 files changed

+151
-2
lines changed

dev/Dockerfile

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,26 @@ RUN \
2424
vim \
2525
wget
2626

27+
ARG SYSTEM_USER_NAME=gituser
28+
ARG GIT_USER_NAME="Git User"
29+
30+
31+
# Create the new git user
32+
RUN useradd -ms /bin/bash $SYSTEM_USER_NAME
33+
34+
# Change the game folder ownership
35+
RUN chown -R $SYSTEM_USER_NAME:$SYSTEM_USER_NAME /SC2
36+
37+
# Setup the git commit environment
38+
USER $SYSTEM_USER_NAME
39+
RUN git config --global user.name "$GIT_USER_NAME"
40+
RUN git config --global user.email "$GIT_EMAIL"
41+
42+
# Generate a new SSH key pair without user input
43+
RUN cat /dev/zero | ssh-keygen -q -N "" > /dev/null
44+
2745
# Add the code
28-
WORKDIR /s2client-api
46+
WORKDIR /home/$SYSTEM_USER_NAME
2947

48+
# Override the s2client-game entrypoint
3049
ENTRYPOINT [ "/bin/bash" ]

dev/README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Setting up your development environment
2+
3+
The developer container is a combination of s2client-game and s2client-api.
4+
5+
The API code has been omitted because it's assumed you will be cloning the repo
6+
and working with GIT to manipuate the API code.
7+
8+
This container will copy your git configuration and system username to the
9+
development container. If you want to override this process see below.
10+
11+
To get setup for developing API code on linux:
12+
13+
~~~
14+
./all.sh
15+
~~~
16+
17+
You will see your github.com public key as the last step of the build process:
18+
19+
~~~
20+
...
21+
Successfully built 11c71c8b3a9b
22+
==== Your github.com SSH public key for the container is:
23+
ssh-rsa XXXXXXXXXXXX2EAAAADAQABAAABAQDf1N64V0NHQEcat3oiE+gTU/q7VPpXvJztRtaQ0X0/rHqGohFI+RVTCAGTsUyzNeVxJDuiPMhV/j9X1rqVV73pcLyM7flgYnriroo19Y3S9np4dPgyR+IeSztBhfCaLSmrVhvscIUlFCcXM8o1mgy8/mUSn5UJJxBdGdRfRt8TrWT7WVnbkLKNv6xUoBWssSNJds6itD/qBjEkZfD4BCP3dXEJL6U6y+HYnIGqv3lByxHhLK+dJ5pU2lGtyypj1/0IsWQVW4F6EaEBtyEy8cOmh17j9FusfhJkply2Xf2q81jm6nHRNsfd1thOAFe2quc0cTfZzX4ZqC9RE9gxwXI/ jrepp@8089fe031125
24+
~~~
25+
26+
You should copy the ssh-rsa .. user@container_id into your github.com settings under the section for SSH keys.
27+
28+
29+
To run the developer container:
30+
~~~
31+
./run.sh
32+
~~~
33+
34+
If you want to configure the container by hand see the docker commands in **./make-container.sh** for the --build-arg overrides needed to setup your git account without a working shell.
35+
36+
37+
# Using the development environment
38+
39+
Once your ssh key is imported to github.com you're ready to start working with the API:
40+
41+
Clone the repository:
42+
~~~
43+
git clone [email protected]:Blizzard/s2client-api.git
44+
~~~
45+
46+
Generate the project build files:
47+
~~~
48+
cd ~/s2client-api
49+
mkdir -p build
50+
cd build && cmake -G "Unix Makefiles" ..
51+
~~~
52+
53+
# To save your work between sessions
54+
55+
Now that you've gotten your container up and running you will want to snapshot your changes:
56+
~~~
57+
./commit-container.sh
58+
~~~
59+
60+
If you want to move files out of your container consider cloning into a volume mount (e.g.: /code):
61+
~~~
62+
docker run -v code:/code -it s2client-username
63+
~~~
64+
65+
Alternative you can copy the files out using 'docker cp':
66+
~~~
67+
.. run your container
68+
export DEV_CONTAINER=`docker ps -l -q`
69+
docker cp $DEV_CONTAINER:/home/username/myfile.txt .
70+
~~~
71+
72+
# Resuming or attaching
73+
74+
To resume your work after **./commit-container.sh**:
75+
76+
~~~
77+
./run-user.sh
78+
~~~
79+
80+
81+
To attach an additional TTY to a running container:
82+
~~~
83+
./attach-user.sh
84+
~~~
85+
86+
# Additional Notes
87+
88+
The game executable will be located in:
89+
90+
**/SC2/${GAME_VERSION}/StarCraftII/Versions/Base${BUILD_VERSION}/SC2_x64

dev/attach-user.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
# This attaches a shell the last user dev container ID
4+
docker exec -it `docker ps -l -q` /bin/bash

dev/commit-container.sh

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+
#
4+
# This commits the last run container (dev) as with the system user
5+
# as a tag.
6+
#
7+
8+
SYSTEM_USER_NAME=`whoami`
9+
LAST_CONTAINER_ID=`docker ps -q -l`
10+
CONTAINER_NAME=s2client-${SYSTEM_USER_NAME}
11+
12+
echo "Committing last container ${LAST_CONTAINER_ID} as ${CONTAINER_NAME}"
13+
docker commit ${LAST_CONTAINER_ID} ${CONTAINER_NAME}

dev/make-container.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,21 @@
55
IMAGE_NAME=s2client-dev
66
SCRIPT_PATH=${0%/*}
77

8+
# Get the current git user to intantiate in the container
9+
SYSTEM_USER_NAME=`whoami`
10+
GIT_USER_NAME=`git config --get user.name`
11+
GIT_EMAIL=`git config --get user.email`
12+
813
echo ${IMAGE_NAME} docker image building using ${SCRIPT_PATH}/Dockerfile
9-
docker build ${SCRIPT_PATH} -t ${IMAGE_NAME}
14+
echo Configuring for GIT user: $SYSTEM_USER_NAME, name: ${GIT_USER_NAME}, email: ${GIT_EMAIL}
15+
16+
docker build ${SCRIPT_PATH} \
17+
--build-arg SYSTEM_USER_NAME=${SYSTEM_USER_NAME} \
18+
--build-arg GIT_USER_NAME="${GIT_USER_NAME}" \
19+
--build-arg GIT_EMAIL="${GIT_EMAIL}" \
20+
-t ${IMAGE_NAME}
21+
22+
echo ==== Your github.com SSH public key for the container is:
23+
24+
# Output the key for usage on github.com
25+
docker run -t ${IMAGE_NAME}:latest -c "/bin/cat /home/${SYSTEM_USER_NAME}/.ssh/id_rsa.pub"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env bash
2+
23
docker run \
34
-v build-mount:/build-mount \
45
-it s2client-dev

dev/run-user.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
# This runs the user dev container
4+
docker run \
5+
-v build-mount:/build-mount \
6+
-it s2client-`whoami`

0 commit comments

Comments
 (0)