Browse Source

Docker docker docker docker docker

master
Chris Smith 6 years ago
parent
commit
dbc1ecda90
4 changed files with 32 additions and 0 deletions
  1. 3
    0
      README.md
  2. 11
    0
      docker/Dockerfile
  3. 4
    0
      docker/entrypoint.sh
  4. 14
    0
      run.sh

+ 3
- 0
README.md View File

@@ -4,6 +4,9 @@ This repository contains my solution to 2017's [Advent of Code](https://adventof
4 4
 are all written in Python 3; one or two may require the [NumPy](http://www.numpy.org/) package, but the rest should
5 5
 work out-of-the-box.
6 6
 
7
+If you have docker installed, simply execute `run.sh` to build a docker image and execute the latest solution
8
+using pypy3. You can specify other days by passing the script names as arguments (e.g. `run.sh 03.py`).
9
+
7 10
 I tend to focus on short, functional solutions where possible, so they may be a bit hard to read. Some solutions are
8 11
 commented to some degree to help with that.
9 12
 

+ 11
- 0
docker/Dockerfile View File

@@ -0,0 +1,11 @@
1
+FROM pypy:3
2
+
3
+RUN pip3 install numpy
4
+
5
+ADD entrypoint.sh /entrypoint.sh
6
+RUN chmod +x /entrypoint.sh
7
+
8
+USER nobody
9
+
10
+CMD /entrypoint.sh
11
+VOLUME /code

+ 4
- 0
docker/entrypoint.sh View File

@@ -0,0 +1,4 @@
1
+#!/bin/bash
2
+
3
+cd /code
4
+time pypy3 ${1:-$(find -regex './[0-9]+.py' | sort | tail -n 1)}

+ 14
- 0
run.sh View File

@@ -0,0 +1,14 @@
1
+#!/bin/bash
2
+
3
+IMAGE=csmith/aoc-2017-01
4
+
5
+docker image inspect $IMAGE >/dev/null 2>&1
6
+if [ $? -ne 0 ]
7
+then
8
+    echo "One time setup: building docker image..."
9
+    cd docker
10
+    docker build . -t $IMAGE
11
+    cd ..
12
+fi
13
+
14
+docker run --rm -it -v $(pwd):/code $IMAGE /entrypoint.sh $@

Loading…
Cancel
Save