2
0
mirror of https://github.com/cmehay/pyentrypoint synced 2024-10-30 15:21:11 +00:00

Fix install dep and add Dockefiles

This commit is contained in:
Christophe Mehay 2016-12-05 23:30:52 +01:00
parent 4b888c3461
commit 14f8cb649a
11 changed files with 100 additions and 30 deletions

5
.dockerignore Normal file
View File

@ -0,0 +1,5 @@
*
!pyentrypoint
!setup.py
!README.md
!tests

17
Dockerfile-test.py2 Normal file
View File

@ -0,0 +1,17 @@
# Testing with python 2
FROM python:2
RUN pip install pytest six pyyaml jinja2 colorlog watchdog pytest-mock
RUN adduser --uid 1009 --system testuser
RUN addgroup --gid 1010 testgroup
ENV PYTHONPATH /opt/
ADD tests/test_template.yml.tpl /tmp/test_template.yml
ADD tests/test_template.yml.tpl /tmp/test_template2.yml.tpl
WORKDIR /opt/tests
CMD ["py.test", "--verbose", "-rw", "."]

17
Dockerfile-test.py3 Normal file
View File

@ -0,0 +1,17 @@
# Testing with python 3
FROM python:3
RUN pip3 install pytest six pyyaml jinja2 colorlog watchdog pytest-mock
RUN adduser --uid 1009 --system testuser
RUN addgroup --gid 1010 testgroup
ENV PYTHONPATH /opt/
ADD tests/test_template.yml.tpl /tmp/test_template.yml
ADD tests/test_template.yml.tpl /tmp/test_template2.yml.tpl
WORKDIR /opt/tests
CMD ["py.test", "--verbose", "-rw", "."]

View File

@ -1,17 +1,12 @@
# Testing with python 2
FROM python:2 FROM python:2
RUN pip install pytest six pyyaml jinja2 colorlog watchdog pytest-mock ADD . /tmp/
RUN adduser --uid 1009 --system testuser RUN cd /tmp && \
RUN addgroup --gid 1010 testgroup pip install --upgrade pip && \
python setup.py install && \
rm -rf *
ENV PYTHONPATH /opt/ ONBUILD ADD entrypoint-config.yml .
ADD tests/test_template.yml.tpl /tmp/test_template.yml ENTRYPOINT ["pyentrypoint"]
ADD tests/test_template.yml.tpl /tmp/test_template2.yml.tpl
WORKDIR /opt/tests
CMD ["py.test", "--verbose", "-rw", "."]

12
Dockerfile.py2-alpine Normal file
View File

@ -0,0 +1,12 @@
FROM python:2-alpine
ADD . /tmp/
RUN cd /tmp && \
pip install --upgrade pip && \
python setup.py install && \
rm -rf *
ONBUILD ADD entrypoint-config.yml .
ENTRYPOINT ["pyentrypoint"]

View File

@ -1,17 +1,12 @@
# Testing with python 3
FROM python:3 FROM python:3
RUN pip3 install pytest six pyyaml jinja2 colorlog watchdog pytest-mock ADD . /tmp/
RUN adduser --uid 1009 --system testuser RUN cd /tmp && \
RUN addgroup --gid 1010 testgroup pip install --upgrade pip && \
python setup.py install && \
rm -rf *
ENV PYTHONPATH /opt/ ONBUILD ADD entrypoint-config.yml .
ADD tests/test_template.yml.tpl /tmp/test_template.yml ENTRYPOINT ["pyentrypoint"]
ADD tests/test_template.yml.tpl /tmp/test_template2.yml.tpl
WORKDIR /opt/tests
CMD ["py.test", "--verbose", "-rw", "."]

12
Dockerfile.py3-alpine Normal file
View File

@ -0,0 +1,12 @@
FROM python:3-alpine
ADD . /tmp/
RUN cd /tmp && \
pip install --upgrade pip && \
python setup.py install && \
rm -rf *
ONBUILD ADD entrypoint-config.yml .
ENTRYPOINT ["pyentrypoint"]

View File

@ -45,6 +45,22 @@ ENTRYPOINT ['pyentrypoint']
CMD ['git'] CMD ['git']
``` ```
#### Using docker-image
```dockerfile
FROM goldy/pyentrypoint:python3
# ONBUILD statement add entrypoint-config.yml in current directories
```
Available with many flavours:
- `goldy/pyentrypoint:python2`
- `goldy/pyentrypoint:python3`
- `goldy/pyentrypoint:python2-alpine`
- `goldy/pyentrypoint:python3-alpine`
### Working examples ### Working examples
- [Tor hidden service](https://github.com/cmehay/docker-tor-hidden-service) - [Tor hidden service](https://github.com/cmehay/docker-tor-hidden-service)

View File

@ -1,6 +1,6 @@
testpython3: testpython3:
build: . build: .
dockerfile: Dockerfile.py3 dockerfile: Dockerfile-test.py3
volumes: volumes:
- ./pyentrypoint:/opt/pyentrypoint:ro - ./pyentrypoint:/opt/pyentrypoint:ro
- ./tests:/opt/tests - ./tests:/opt/tests
@ -15,7 +15,7 @@ testpython3:
testpython2: testpython2:
build: . build: .
dockerfile: Dockerfile.py2 dockerfile: Dockerfile-test.py2
volumes: volumes:
- ./pyentrypoint:/opt/pyentrypoint:ro - ./pyentrypoint:/opt/pyentrypoint:ro
- ./tests:/opt/tests - ./tests:/opt/tests
@ -30,7 +30,7 @@ testpython2:
testpython3_debug: testpython3_debug:
build: . build: .
dockerfile: Dockerfile.py3 dockerfile: Dockerfile-test.py3
volumes: volumes:
- ./pyentrypoint:/opt/pyentrypoint:ro - ./pyentrypoint:/opt/pyentrypoint:ro
- ./tests:/opt/tests - ./tests:/opt/tests
@ -46,7 +46,7 @@ testpython3_debug:
testpython2_debug: testpython2_debug:
build: . build: .
dockerfile: Dockerfile.py2 dockerfile: Dockerfile-test.py2
volumes: volumes:
- ./pyentrypoint:/opt/pyentrypoint:ro - ./pyentrypoint:/opt/pyentrypoint:ro
- ./tests:/opt/tests - ./tests:/opt/tests

View File

@ -79,6 +79,8 @@ class Command(object):
self.log.debug('Now running: "{args}"'.format( self.log.debug('Now running: "{args}"'.format(
args='" "'.join(self.args) args='" "'.join(self.args)
)) ))
if not self.args[0]:
raise Exception('Nothing to run')
os.execvpe(self.args[0], self.args, self.env) os.execvpe(self.args[0], self.args, self.env)
def _run_reloader(self): def _run_reloader(self):

View File

@ -5,7 +5,7 @@ from setuptools import setup
# Thanks Sam and Max # Thanks Sam and Max
__version__ = '0.4.6' __version__ = '0.4.7'
if __name__ == '__main__': if __name__ == '__main__':
setup( setup(
@ -27,7 +27,6 @@ if __name__ == '__main__':
install_requires=['Jinja2>=2.8', install_requires=['Jinja2>=2.8',
'PyYAML>=3.11', 'PyYAML>=3.11',
'colorlog>=2.6.1', 'colorlog>=2.6.1',
'argparse>=1.4.0',
'six>=1.10.0', 'six>=1.10.0',
'watchdog>=0.8.3'], 'watchdog>=0.8.3'],