Commit 1f1b36e9 authored by Philippe Pepiot's avatar Philippe Pepiot
Browse files

Introduce docker-cubicweb-helper command

Since we're going to add new commands helpers in the docker image in following
changesets, introduce a "docker-cubicweb-helper" command that will be used to
add new commands.

Start replacing "get-cube" by "docker-cubicweb-helper get-cube".
parent 773eeef6314a
......@@ -4,3 +4,4 @@
!entrypoint.sh
!check-docker-updates.sh
!get-cube
!docker-cubicweb-helper
......@@ -21,8 +21,8 @@ RUN apt-get update && apt-get -y --no-install-recommends install \
RUN test $PYTHON = "python" && export py=python2 pip=pip2 || export py=python3 pip=pip3; \
update-alternatives --install /usr/bin/python python /usr/bin/$py 50 && \
update-alternatives --install /usr/bin/pip pip /usr/bin/$pip 50
COPY check-docker-updates.sh get-cube /usr/local/bin/
RUN chmod +x /usr/local/bin/check-docker-updates.sh /usr/local/bin/get-cube
COPY docker-cubicweb-helper check-docker-updates.sh get-cube /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-cubicweb-helper /usr/local/bin/check-docker-updates.sh /usr/local/bin/get-cube
ENV PIP_NO_CACHE_DIR off
ENV PIP_DISABLE_PIP_VERSION_CHECK on
# Markdown require setuptools>=36
......
......@@ -6,4 +6,4 @@ ONBUILD USER root
ONBUILD COPY . /src/
ONBUILD RUN pip install -e /src
ONBUILD USER cubicweb
ONBUILD RUN cubicweb-ctl create $(get-cube) $CW_INSTANCE --automatic --no-db-create
ONBUILD RUN cubicweb-ctl create $(docker-cubicweb-helper get-cube) $CW_INSTANCE --automatic --no-db-create
#!/usr/bin/env python
from __future__ import print_function
import argparse
import logging
import os
import pkg_resources
import subprocess
import sys
LOG = logging.getLogger(__name__)
def _get_cube():
if os.environ.get('CUBE'):
return os.environ['CUBE']
name = subprocess.check_output(
['python', 'setup.py', '--name'], cwd='/src').decode().strip()
cubename = list(pkg_resources.get_distribution(
name).get_entry_map('cubicweb.cubes').keys())
assert len(cubename) == 1, (
"You should have exactly one entrypoint for 'cubicweb.cubes' "
"entrypoint in setup.py: got {0}".format(repr(cubename)))
return cubename[0]
def get_cube():
print(_get_cube())
if __name__ == '__main__':
logging.basicConfig(format='%(asctime)-15s %(message)s')
LOG.setLevel(logging.INFO)
parser = argparse.ArgumentParser(description='docker cubicweb helper')
sub = parser.add_subparsers()
get_cube_parser = sub.add_parser(
'get-cube', help='get top level cubicweb cube')
get_cube_parser.set_defaults(func=get_cube)
args = vars(parser.parse_args())
func = args.pop('func')
sys.exit(func(**args))
#!/bin/sh
set -e
export CUBE=$(get-cube)
export CUBE=$(docker-cubicweb-helper get-cube)
test -z "$CUBE" && exit 1
if test -z "$CW_DB_NAME"; then
export CW_DB_NAME=$CUBE
......
#!/usr/bin/env python
from __future__ import print_function
import os
import pkg_resources
import subprocess
def getcube():
if os.environ.get('CUBE'):
return os.environ['CUBE']
name = subprocess.check_output(
['python', 'setup.py', '--name'], cwd='/src').decode().strip()
cubename = list(pkg_resources.get_distribution(
name).get_entry_map('cubicweb.cubes').keys())
assert len(cubename) == 1, (
"You should have exactly one entrypoint for 'cubicweb.cubes' "
"entrypoint in setup.py: got {0}".format(repr(cubename)))
return cubename[0]
if __name__ == '__main__':
print(getcube())
#!/bin/sh
>&2 echo "get-cube is DEPRECATED, use 'docker-cubicweb-helper get-cube' instead"
exec docker-cubicweb-helper get-cube
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment