#90 build app.js outside of main Docker image

This commit is contained in:
Henning Jacobs
2017-01-14 15:45:26 +01:00
parent c9d0bdb1fb
commit 05fca4a089
8 changed files with 116 additions and 17 deletions

3
.gitignore vendored
View File

@@ -9,3 +9,6 @@ npm-debug.log*
.tox/
*.egg*
dist/
scm-source.json
.cache/
.coverage

View File

@@ -1,7 +1,10 @@
language: node_js
node_js:
- '6'
before_script:
language: python
python:
- "3.5"
install:
- pip install tox tox-travis coveralls
- npm install -g eslint
script:
- cd app && eslint src
- tox
after_success:
- coveralls

View File

@@ -1,22 +1,21 @@
FROM alpine:3.4
FROM alpine:3.5
MAINTAINER Henning Jacobs <henning@jacobs1.de>
RUN apk add --no-cache python3 python3-dev alpine-sdk zlib-dev libffi-dev openssl-dev nodejs ca-certificates && \
EXPOSE 8080
RUN apk add --no-cache python3 python3-dev gcc musl-dev zlib-dev libffi-dev openssl-dev ca-certificates && \
python3 -m ensurepip && \
rm -r /usr/lib/python*/ensurepip && \
pip3 install --upgrade pip setuptools gevent && \
apk del python3-dev alpine-sdk zlib-dev libffi-dev openssl-dev && \
apk del python3-dev gcc musl-dev zlib-dev libffi-dev openssl-dev && \
rm -rf /var/cache/apk/* /root/.cache /tmp/*
EXPOSE 8080
COPY scm-source.json /
COPY requirements.txt /
RUN pip3 install -r /requirements.txt
COPY kube_ops_view /
COPY app /app
WORKDIR /app
RUN npm install && npm run build
COPY kube_ops_view /kube_ops_view
WORKDIR /
ENTRYPOINT ["/usr/bin/python3", "-m", "kube_ops_view"]

34
Makefile Normal file
View File

@@ -0,0 +1,34 @@
.PHONY: clean
IMAGE ?= hjacobs/kube-ops-view
TAG ?= latest
GITHEAD = $(shell git rev-parse --short HEAD)
GITURL = $(shell git config --get remote.origin.url)
GITSTATUS = $(shell git status --porcelain || echo "no changes")
default: docker
build: appjs docker
clean:
rm -fr kube_ops_view/static/build
test:
tox
appjs:
docker run -it -u $$(id -u) -v $$(pwd):/workdir -w /workdir/app node:7.4-alpine npm install
docker run -it -u $$(id -u) -v $$(pwd):/workdir -w /workdir/app node:7.4-alpine npm run build
docker: appjs scm-source.json
docker build -t "$(IMAGE):$(TAG)" .
push: docker
docker push "$(IMAGE):$(TAG)"
mock:
docker run -it -p 8080:8080 -e MOCK=true "$(IMAGE):$(TAG)"
scm-source.json: .git
@echo '{"url": "$(GITURL)", "revision": "$(GITHEAD)", "author": "$(USER)", "status": "$(GITSTATUS)"}' > scm-source.json

View File

@@ -83,6 +83,16 @@ You can also run the latest Docker image directly:
$ docker run -it -p 8080:8080 -e MOCK=true hjacobs/kube-ops-view
Building
========
The provided ``Makefile`` will generate a Docker image by default:
.. code-block:: bash
$ make
Multiple Clusters
=================

View File

@@ -1,11 +1,41 @@
import sys
from setuptools import find_packages, setup
from setuptools.command.test import test as TestCommand
class PyTest(TestCommand):
user_options = [('cov-html=', None, 'Generate junit html report')]
def initialize_options(self):
TestCommand.initialize_options(self)
self.cov = None
self.pytest_args = ['--cov', 'kube_ops_view', '--cov-report', 'term-missing', '-v']
self.cov_html = False
def finalize_options(self):
TestCommand.finalize_options(self)
if self.cov_html:
self.pytest_args.extend(['--cov-report', 'html'])
self.pytest_args.extend(['tests'])
def run_tests(self):
import pytest
errno = pytest.main(self.pytest_args)
sys.exit(errno)
def readme():
return open('README.rst', encoding='utf-8').read()
tests_require = [
'pytest',
'pytest-cov'
]
setup(
name='kube-ops-view',
packages=find_packages(),
@@ -16,6 +46,10 @@ setup(
url='https://github.com/hjacobs/kube-ops-view',
keywords='kubernetes operations dashboard view k8s',
license='GNU General Public License v3 (GPLv3)',
tests_require=tests_require,
extras_require={'tests': tests_require},
cmdclass={'test': PyTest},
test_suite='tests',
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',

5
tests/test_mock.py Normal file
View File

@@ -0,0 +1,5 @@
from kube_ops_view.mock import get_mock_clusters
def test_get_mock_clusters():
get_mock_clusters()

17
tox.ini
View File

@@ -1,12 +1,23 @@
[tox]
envlist=flake8
envlist=py35,flake8,eslint
[tox:travis]
3.5=flake8
3.5=py35,flake8,eslint
[testenv]
deps=pytest
commands=
pip install -r requirements.txt
python setup.py test
[testenv:flake8]
deps=flake8
commands=flake8
commands=python setup.py flake8
[testenv:eslint]
whitelist_externals=eslint
changedir=app
commands=eslint src
[flake8]
max-line-length=160