Skip to content

Commit

Permalink
Merge pull request #69 from izrik/docker
Browse files Browse the repository at this point in the history
Docker
  • Loading branch information
izrik committed Jun 18, 2018
2 parents aff2739 + 5361555 commit a9209ea
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 3 deletions.
76 changes: 76 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Byte-compiled / optimized / DLL files
__pycache__/
**/*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# PyCharm
.idea

# virtualenv
bin
include
Scripts
.venv

# tudor test things
tudor_tasks.p
test.db
set_env.sh
.tudor
set-env.sh

# scratch files
_scratch*

# coveralls
.coveralls.yml
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ sudo: false
install:
- pip install -r requirements.txt
- pip install -r dev_requirements.txt
- npm install -g markdownlint-cli
- npm install -g csslint
- npm install -g markdownlint-cli csslint dockerlint dockerfile_lint
script:
- ./run_tests_with_coverage.sh
after_success:
Expand Down
33 changes: 33 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM python:2.7

ENV PLANTAGENET_VERSION=0.1
LABEL \
Name="plantagenet" \
Version="$PLANTAGENET_VERSION" \
Summary="A Python blogging system." \
Description="A Python blogging system." \
maintaner="izrik <izrik@izrikrackspace.com>"

RUN mkdir -p /opt/plantagenet

WORKDIR /opt/plantagenet

COPY plantagenet.py \
LICENSE \
README.md \
requirements.txt \
docker_start.sh \
./

COPY static static
COPY templates templates

RUN pip install -r requirements.txt
RUN pip install gunicorn==19.8.1
RUN pip install MySQL-python==1.2.5

EXPOSE 8080
ENV PLANTAGENET_PORT=8080 \
PLANTAGENET_HOST=0.0.0.0

CMD ["/opt/plantagenet/docker_start.sh"]
4 changes: 4 additions & 0 deletions docker_start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

python /opt/plantagenet/plantagenet.py --create-db
gunicorn -b $PLANTAGENET_HOST:$PLANTAGENET_PORT plantagenet:app
5 changes: 5 additions & 0 deletions plantagenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
from werkzeug.exceptions import ServiceUnavailable
from werkzeug.exceptions import Unauthorized

__version__ = '0.1'
try:
__revision__ = git.Repo('.').git.describe(tags=True, dirty=True,
always=True, abbrev=40)
Expand Down Expand Up @@ -289,6 +290,10 @@ def get_siteurl():
def get_revision():
return __revision__

@staticmethod
def get_version():
return __version__

@staticmethod
def seq():
i = 0
Expand Down
7 changes: 7 additions & 0 deletions run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,13 @@ def test_reset_slug_missing(self):
self.assertRaises(NotFound, plantagenet.reset_slug, 1)


class VersionTest(unittest.TestCase):
def test_version_number_is_correct(self):
from plantagenet import Options
# expect
self.assertEqual('0.1', Options.get_version())


def run():
parser = argparse.ArgumentParser()
parser.add_argument('--print-log', action='store_true',
Expand Down
5 changes: 4 additions & 1 deletion run_tests_with_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ coverage run --source=plantagenet ./run_tests.py "$@" && \
shellcheck run_tests_with_coverage.sh && \
markdownlint README.md && \
csslint static/plantagenet.css && \
safety check
safety check && \
dockerlint Dockerfile && \
dockerfile_lint Dockerfile &&
echo Success
1 change: 1 addition & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<small>Copyright &copy; 2017 by {{ Options.get_author() }}.</small><br/>
{% endblock %}
<small>Powered by <a href="https://github.com/izrik/plantagenet">plantagenet</a>.</small><br/>
<small>Version: <code>{{ Options.get_version() }}</code></small><br/>
<small>Revision: <code>{{ Options.get_revision() }}</code></small>
</div>
{% endblock %}
Expand Down

0 comments on commit a9209ea

Please sign in to comment.