Permalink
Browse files

Merge pull request #1 from ShaneMcC/master

Add docker.sh for running in docker.
  • Loading branch information...
tsumaru720 committed Dec 2, 2018
2 parents 88a9da6 + e318b81 commit 7e53b2029bc3b4d891c685977994dea019485c1c
Showing with 62 additions and 0 deletions.
  1. +14 −0 docker.sh
  2. +13 −0 docker/Dockerfile
  3. +21 −0 docker/entrypoint.sh
  4. +14 −0 docker/runBoth.sh
@@ -0,0 +1,14 @@
#!/bin/bash

IMAGE=tsumaru720/aoc-01

docker image inspect $IMAGE >/dev/null 2>&1
if [ $? -ne 0 ]
then
echo "One time setup: building docker image..."
cd docker
docker build . -t $IMAGE
cd ..
fi

docker run --rm -it -v $(pwd):/code $IMAGE /entrypoint.sh $@
@@ -0,0 +1,13 @@
FROM php:7.2-cli

RUN apt-get update \
&& apt-get -y install pypy

ADD entrypoint.sh /entrypoint.sh
ADD runBoth.sh /runBoth.sh
RUN chmod +x /entrypoint.sh /runBoth.sh

USER nobody

CMD /entrypoint.sh
VOLUME /code
@@ -0,0 +1,21 @@
#!/bin/bash

YEAR="${1}"
DAY="${2}"

if ! [[ "${YEAR}" =~ ^[0-9]+$ ]]; then
echo 'Invalid Year: '${YEAR};
exit 1;
fi;

if ! [[ "${DAY}" =~ ^[0-9]+$ ]]; then
echo 'Invalid Day: '${DAY};
exit 1;
fi;

if [ ! -e "/code/${YEAR}/${DAY}/" ]; then
echo 'Unknown Year/Day: '${YEAR}'/'${DAY};
exit 1;
fi;

time /runBoth.sh ${YEAR} ${DAY}
@@ -0,0 +1,14 @@
#!/bin/bash

YEAR="${1}"
DAY="${2}"

cd /code/${YEAR}/${DAY}/

if [ -e "run.php" ]; then
php run.php 1
php run.php 2
elif [ -e "day${DAY}.py" ]; then
pypy day${DAY}.py 1
pypy day${DAY}.py 2
fi;

0 comments on commit 7e53b20

Please sign in to comment.