Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.

Commit b87bae4

Browse files
committed
Updated readme, added docker compose configuration
1 parent 2daa4d4 commit b87bae4

File tree

4 files changed

+337
-11
lines changed

4 files changed

+337
-11
lines changed

README.md

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,32 @@ Within each Docker image, there is a copy of the Node executable and a `run` scr
2020
for executing code. For example to run a simple javascript script which would output `2`:
2121

2222
```
23+
# this is how you run the Node CLI. For this to work you would have to be bash into the correct Docker image
2324
node run -l javascript -c "console.log(1+1)"
2425
```
2526

2627
Because everything runs inside of Docker, you would normally not run Node directly from your host but instead via a Docker run command.
27-
To do this, you would need to choose the right Docker image for the language you wish to execute.
28+
To do this, you would either bash into the corret Docker image like so:
2829

2930
```
31+
# direct Docker call:
32+
docker run --rm -it codewars/node-runner bash
33+
34+
# alternatively you can use the provided Docker Compose configuration:
35+
docker-compose run node-runner
36+
```
37+
38+
Or you could choose to execute the code outside of Docker by creating a container that will remove itself after it executes:
39+
40+
```
41+
42+
# direct Docker call:
3043
docker run --rm codewars/node-runner run -l javascript -c "console.log('I ran inside of Docker using NodeJS')"
3144
docker run --rm codewars/ruby-runner run -l ruby -c "puts 'I ran inside of Docker using Ruby'"
45+
46+
# alternatively you can use the provided Docker Compose configuration:
47+
docker-compose run javascript -c "console.log('I ran inside of Docker using NodeJS')"
48+
docker-compose run ruby -c "puts 'I ran inside of Docker using Ruby'"
3249
```
3350

3451
### Integrated Test Suites
@@ -39,7 +56,11 @@ code testing methods.
3956
Here is a very simple example of running tests using the simplified CW testing framework.
4057

4158
```
42-
docker run --rm codewars/node-runner run -l javascript -c "var a = 1;" -t cw -f "Test.assertEquals(a, 1)"
59+
# manually running docker
60+
docker run --rm codewars/node-runner run -l javascript -c "var a = 1;" -t cw -f "Test.assertEquals(a, 1)"
61+
62+
# using docker compose
63+
docker-compose run javascript -c "var a = 1;" -t cw -f "Test.assertEquals(a, 1)"
4364
```
4465

4566
Which would output `<PASSED::>Test Passed: Value == 1` to STDOUT.
@@ -98,7 +119,15 @@ have to worry about having any of the project dependencies loaded directly on yo
98119
Run the following command:
99120

100121
```
101-
docker run -it --rm --entrypoint bash -v $(pwd)/lib:/runner/lib -v $(pwd)/examples:/runner/examples -v $(pwd)/frameworks:/runner/frameworks -v $(pwd)/test:/runner/test codewars/node-runner
122+
docker run \
123+
-it \
124+
--rm \
125+
--entrypoint bash \
126+
-v $(pwd)/lib:/runner/lib \
127+
-v $(pwd)/examples:/runner/examples \
128+
-v $(pwd)/frameworks:/runner/frameworks \
129+
-v $(pwd)/test:/runner/test \
130+
codewars/node-runner
102131
```
103132

104133
This will create a new container and send you into the instance with your project's lib and test directories mounted
@@ -108,9 +137,15 @@ from within the container.
108137
**Notice**: We did not mount the entire directory because that would overwrite things such as your node_modules directory. If you need
109138
to update these you should `make {image_you_want_to_update}` the image to ensure you are always testing against the correct packages.
110139

111-
If you already have Node installed on your host machine, you can just manage your node_module packages locally for an easier development
112-
flow. This would allow you to just mount your entire source directory.
113-
In this case you would run `npm install` and then `docker run -it --rm --entrypoint bash -v $(pwd):/runner codewars/node-runner`.
140+
### Docker Compose
141+
We mentioned before that you also have the option of using Docker Compose to run the CLI tool. We have setup the `docker-compose.yml`
142+
file to provide very useful pre-configured services for making development easier. Instead of having to issue the long command
143+
mentioned above, you can simply run `docker-compose run node_runner` to bash into a fresh container with your local volumes already mounted.
144+
145+
All of the docker compose services are setup to mount volumes for easier developer, so that is the recommended way of
146+
interacting with the codebase. You should note though that the compose file is unable to build images due to how
147+
the directory structure is layed out, so you have to first `make {runner_name}` the image before you can run it. Otherwise
148+
it will pull down the latest copy from Docker Hub.
114149

115150
### Running Tests
116151

@@ -119,6 +154,9 @@ Once you are in the Docker image, you can run tests as a part of your developmen
119154
```
120155
# inside of container
121156
mocha test/runners/typescript_spec.js
157+
158+
# or from outside the container
159+
docker-compose run typescript_test
122160
```
123161

124162
## Test Suite Output Format
@@ -167,11 +205,12 @@ state so not all steps may be needed in your case
167205

168206
1. Install the language and its related packages on one of the Docker images. We have grouped many of the Docker images
169207
together so if that grouping makes sense then add it there, otherwise you will need to create a new docker image within
170-
the docker folder and add that image to the Makefile.
171-
2. Add a new runner script within `lib/runners`. More details about this script later on.
172-
3. Add a new runner spec within `test/runners`. You will also need to add the runner spec to the Docker image so that
208+
the docker folder
209+
1. Add the newly created docker file to the Make and docker-compose files (if applicable)
210+
1. Add a new runner script within `lib/runners`. More details about this script later on.
211+
1. Add a new runner spec within `test/runners`. You will also need to add the runner spec to the Docker image so that
173212
it is tested as a part of the build process.
174-
4. Add a new examples yml file within the `examples` folder. These are the code examples that are used on Codewars.com
213+
1. Add a new examples yml file within the `examples` folder. These are the code examples that are used on Codewars.com
175214
when a user clicks the "Insert Example" button within the kata editor. There is also a helper available for running your examples
176215
as a part of the test suite.
177216

docker-compose.yml

Lines changed: 272 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,272 @@
1+
version: '2'
2+
services:
3+
node-runner:
4+
image: codewars/node-runner
5+
volumes:
6+
- ./lib:/runner/lib
7+
- ./examples:/runner/examples
8+
- ./frameworks:/runner/frameworks
9+
- ./test:/runner/test
10+
entrypoint: ''
11+
command: bash
12+
13+
jvm-runner:
14+
image: codewars/jvm-runner
15+
volumes:
16+
- ./lib:/runner/lib
17+
- ./examples:/runner/examples
18+
- ./frameworks:/runner/frameworks
19+
- ./test:/runner/test
20+
entrypoint: ''
21+
command: bash
22+
23+
ruby-runner:
24+
image: codewars/ruby-runner
25+
volumes:
26+
- ./lib:/runner/lib
27+
- ./examples:/runner/examples
28+
- ./frameworks:/runner/frameworks
29+
- ./test:/runner/test
30+
entrypoint: ''
31+
command: bash
32+
33+
python-runner:
34+
image: codewars/python-runner
35+
volumes:
36+
- ./lib:/runner/lib
37+
- ./examples:/runner/examples
38+
- ./frameworks:/runner/frameworks
39+
- ./test:/runner/test
40+
entrypoint: ''
41+
command: bash
42+
43+
func-runner:
44+
image: codewars/func-runner
45+
volumes:
46+
- ./lib:/runner/lib
47+
- ./examples:/runner/examples
48+
- ./frameworks:/runner/frameworks
49+
- ./test:/runner/test
50+
entrypoint: ''
51+
command: bash
52+
53+
systems-runner:
54+
image: codewars/systems-runner
55+
volumes:
56+
- ./lib:/runner/lib
57+
- ./examples:/runner/examples
58+
- ./frameworks:/runner/frameworks
59+
- ./test:/runner/test
60+
entrypoint: ''
61+
command: bash
62+
63+
erlang-runner:
64+
image: codewars/erlang-runner
65+
volumes:
66+
- ./lib:/runner/lib
67+
- ./examples:/runner/examples
68+
- ./frameworks:/runner/frameworks
69+
- ./test:/runner/test
70+
entrypoint: ''
71+
command: bash
72+
73+
alt-runner:
74+
image: codewars/alt-runner
75+
volumes:
76+
- ./lib:/runner/lib
77+
- ./examples:/runner/examples
78+
- ./frameworks:/runner/frameworks
79+
- ./test:/runner/test
80+
entrypoint: ''
81+
command: bash
82+
83+
dotnet-runner:
84+
image: codewars/alt-runner
85+
volumes:
86+
- ./lib:/runner/lib
87+
- ./examples:/runner/examples
88+
- ./frameworks:/runner/frameworks
89+
- ./test:/runner/test
90+
entrypoint: ''
91+
command: bash
92+
93+
# LANGUAGE SPECIFIC HELPERS
94+
javascript:
95+
image: codewars/node-runner
96+
volumes:
97+
- ./lib:/runner/lib
98+
- ./examples:/runner/examples
99+
- ./frameworks:/runner/frameworks
100+
- ./test:/runner/test
101+
entrypoint: 'node run -l javascript'
102+
103+
javascript_test:
104+
image: codewars/node-runner
105+
volumes:
106+
- ./lib:/runner/lib
107+
- ./examples:/runner/examples
108+
- ./frameworks:/runner/frameworks
109+
- ./test:/runner/test
110+
entrypoint: 'mocha -t 5000 test/runners/javascript_spec.js'
111+
112+
coffeescript:
113+
image: codewars/node-runner
114+
volumes:
115+
- ./lib:/runner/lib
116+
- ./examples:/runner/examples
117+
- ./frameworks:/runner/frameworks
118+
- ./test:/runner/test
119+
entrypoint: 'node run -l coffeescript'
120+
121+
coffeescript_test:
122+
image: codewars/node-runner
123+
volumes:
124+
- ./lib:/runner/lib
125+
- ./examples:/runner/examples
126+
- ./frameworks:/runner/frameworks
127+
- ./test:/runner/test
128+
entrypoint: 'mocha -t 5000 test/runners/coffeescript_spec.js'
129+
130+
typescript:
131+
image: codewars/node-runner
132+
volumes:
133+
- ./lib:/runner/lib
134+
- ./examples:/runner/examples
135+
- ./frameworks:/runner/frameworks
136+
- ./test:/runner/test
137+
entrypoint: 'node run -l typescript'
138+
139+
typescript_test:
140+
image: codewars/node-runner
141+
volumes:
142+
- ./lib:/runner/lib
143+
- ./examples:/runner/examples
144+
- ./frameworks:/runner/frameworks
145+
- ./test:/runner/test
146+
entrypoint: 'mocha -t 5000 test/runners/typescript_spec.js'
147+
148+
python:
149+
image: codewars/python-runner
150+
volumes:
151+
- ./lib:/runner/lib
152+
- ./examples:/runner/examples
153+
- ./frameworks:/runner/frameworks
154+
- ./test:/runner/test
155+
entrypoint: 'node run -l python'
156+
157+
python_test:
158+
image: codewars/python-runner
159+
volumes:
160+
- ./lib:/runner/lib
161+
- ./examples:/runner/examples
162+
- ./frameworks:/runner/frameworks
163+
- ./test:/runner/test
164+
entrypoint: 'mocha -t 5000 test/runners/python_spec.js'
165+
166+
python3:
167+
image: codewars/python-runner
168+
volumes:
169+
- ./lib:/runner/lib
170+
- ./examples:/runner/examples
171+
- ./frameworks:/runner/frameworks
172+
- ./test:/runner/test
173+
entrypoint: 'node run -l python3'
174+
175+
python3_test:
176+
image: codewars/python-runner
177+
volumes:
178+
- ./lib:/runner/lib
179+
- ./examples:/runner/examples
180+
- ./frameworks:/runner/frameworks
181+
- ./test:/runner/test
182+
entrypoint: 'mocha -t 5000 test/runners/python3_spec.js'
183+
184+
ruby:
185+
image: codewars/ruby-runner
186+
volumes:
187+
- ./lib:/runner/lib
188+
- ./examples:/runner/examples
189+
- ./frameworks:/runner/frameworks
190+
- ./test:/runner/test
191+
entrypoint: 'node run -l ruby'
192+
193+
ruby_test:
194+
image: codewars/ruby-runner
195+
volumes:
196+
- ./lib:/runner/lib
197+
- ./examples:/runner/examples
198+
- ./frameworks:/runner/frameworks
199+
- ./test:/runner/test
200+
entrypoint: 'mocha -t 5000 test/runners/ruby_spec.js'
201+
202+
haskell:
203+
image: codewars/func-runner
204+
volumes:
205+
- ./lib:/runner/lib
206+
- ./examples:/runner/examples
207+
- ./frameworks:/runner/frameworks
208+
- ./test:/runner/test
209+
entrypoint: 'node run -l haskell'
210+
211+
haskell_test:
212+
image: codewars/func-runner
213+
volumes:
214+
- ./lib:/runner/lib
215+
- ./examples:/runner/examples
216+
- ./frameworks:/runner/frameworks
217+
- ./test:/runner/test
218+
entrypoint: 'mocha -t 5000 test/runners/haskell_spec.js'
219+
220+
java:
221+
image: codewars/jvm-runner
222+
volumes:
223+
- ./lib:/runner/lib
224+
- ./examples:/runner/examples
225+
- ./frameworks:/runner/frameworks
226+
- ./test:/runner/test
227+
entrypoint: 'node run -l java'
228+
229+
java_test:
230+
image: codewars/jvm-runner
231+
volumes:
232+
- ./lib:/runner/lib
233+
- ./examples:/runner/examples
234+
- ./frameworks:/runner/frameworks
235+
- ./test:/runner/test
236+
entrypoint: 'mocha -t 5000 test/runners/java_spec.js'
237+
238+
clojure:
239+
image: codewars/jvm-runner
240+
volumes:
241+
- ./lib:/runner/lib
242+
- ./examples:/runner/examples
243+
- ./frameworks:/runner/frameworks
244+
- ./test:/runner/test
245+
entrypoint: 'node run -l clojure'
246+
247+
clojure_test:
248+
image: codewars/jvm-runner
249+
volumes:
250+
- ./lib:/runner/lib
251+
- ./examples:/runner/examples
252+
- ./frameworks:/runner/frameworks
253+
- ./test:/runner/test
254+
entrypoint: 'mocha -t 5000 test/runners/clojure_spec.js'
255+
256+
csharp:
257+
image: codewars/dotnet-runner
258+
volumes:
259+
- ./lib:/runner/lib
260+
- ./examples:/runner/examples
261+
- ./frameworks:/runner/frameworks
262+
- ./test:/runner/test
263+
entrypoint: 'node run -l csharp'
264+
265+
csharp_test:
266+
image: codewars/dotnet-runner
267+
volumes:
268+
- ./lib:/runner/lib
269+
- ./examples:/runner/examples
270+
- ./frameworks:/runner/frameworks
271+
- ./test:/runner/test
272+
entrypoint: 'mocha -t 5000 test/runners/csharp_spec.js'

0 commit comments

Comments
 (0)