feat: added Docker support

This commit is contained in:
jota 2017-06-09 04:20:25 +02:00
parent cacafd06b2
commit 1513afc241
5 changed files with 63 additions and 0 deletions

10
.gitignore vendored
View File

@ -6,4 +6,14 @@
*.egg-info
pokedex.sqlite
pokedex.sqlite-journal
whoosh-index
pip-selfcheck.json
/bin
!/bin/edit-csv-as-yaml
!/bin/poupdate
!/bin/reset-postgresql-sequences
/local
/lib
/include

23
Dockerfile Normal file
View File

@ -0,0 +1,23 @@
FROM python:2.7-slim
RUN echo "Upgrading distro..." && \
apt-get update > /dev/null && \
apt-get upgrade -y > /dev/null && \
echo "Installing dependencies..." && \
apt-get install -y git python-distribute > /dev/null && \
pip install --no-cache-dir virtualenv psycopg2 pymysql > /dev/null && \
echo "Optimizing space..." && \
apt-get remove --purge -y software-properties-common > /dev/null && \
apt-get autoremove -y > /dev/null && \
apt-get clean > /dev/null && \
apt-get autoclean > /dev/null && \
echo -n > /var/lib/apt/extended_states && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /usr/share/man/?? && \
rm -rf /usr/share/man/??_*
COPY ./docker-entrypoint.sh /docker-entrypoint
RUN chmod +x /docker-entrypoint
ENTRYPOINT ["/docker-entrypoint"]
CMD ["status"]

6
docker-compose.yml Normal file
View File

@ -0,0 +1,6 @@
version: '3'
services:
pokedex:
build: ./
volumes:
- ./:/project

21
docker-entrypoint.sh Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -e
POKEDEX_DIR=${POKEDEX_DIR:-"/project"}
cd ${POKEDEX_DIR}
if [ ! -f "${POKEDEX_DIR}/bin/python" ] || [ ! -f "${POKEDEX_DIR}/bin/pokedex" ] ; then
echo "Building the bin/pokedex executable ..."
virtualenv $POKEDEX_DIR --python=python2
bin/python setup.py develop
fi
case "$1" in
"") bin/pokedex help
;;
"exec") exec ${@:2}
;;
*) bin/pokedex $@
;;
esac

3
docker-pokedex Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
docker-compose run --rm pokedex "$@"