Skip to content
This repository was archived by the owner on Jan 2, 2023. It is now read-only.

Commit dbc1ecd

Browse files
committed
Docker docker docker docker docker
1 parent ed28564 commit dbc1ecd

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ This repository contains my solution to 2017's [Advent of Code](https://adventof
44
are all written in Python 3; one or two may require the [NumPy](http://www.numpy.org/) package, but the rest should
55
work out-of-the-box.
66

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+
710
I tend to focus on short, functional solutions where possible, so they may be a bit hard to read. Some solutions are
811
commented to some degree to help with that.
912

docker/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

docker/entrypoint.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
cd /code
4+
time pypy3 ${1:-$(find -regex './[0-9]+.py' | sort | tail -n 1)}

run.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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 $@

0 commit comments

Comments
 (0)