Commit 4eaca20b authored by Philippe Pepiot's avatar Philippe Pepiot

Use debian packages from apt.logilab.fr

We now have working repositories at:

deb http://apt.logilab.fr {stretch,buster} {main,cubicweb-{3.25,3.26}}

Use them instead of pip for base logilab/cubicweb images.

* All images now have a apt looking for packages in /repo
* Images for cubicweb 3.25 and 3.26 use packages from relevant repository
* logilab/cubicweb:dev image use the new "buildpackage" image to build a
  package from latest public changeset of cubicweb.

Packages to be installed differ given cubicweb and python versions, this is why
we introduce a PACKAGES build ARG.

We can now drop support for pip in "check-docker-updates.sh" script, since apt
list --upgradable will detect new packages.
parent 8df7fb37200
......@@ -23,10 +23,11 @@ RUN test $PYTHON = "python" && export py=python2 pip=pip2 || export py=python3 p
update-alternatives --install /usr/bin/pip pip /usr/bin/$pip 50
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
RUN mkdir /repo
RUN echo -n "" | gzip -9c > /repo/Packages.gz
RUN echo "deb [trusted=yes] file:///repo ./" > /etc/apt/sources.list.d/local.list
ENV PIP_NO_CACHE_DIR off
ENV PIP_DISABLE_PIP_VERSION_CHECK on
# Markdown require setuptools>=36
RUN pip install 'setuptools>=36'
RUN useradd cubicweb --uid 1000 -m -s /bin/bash
RUN install -d -o cubicweb -g cubicweb /etc/cubicweb.d
COPY uwsgi.ini /etc/uwsgi/uwsgi.ini
......
ARG DIST
ARG FROM
FROM logilab/cubicweb:$DIST-buildpackage as build
ARG SOURCE_TARBALL
RUN if test -n "$SOURCE_TARBALL"; then buildpackage -u "$SOURCE_TARBALL"; fi
FROM $FROM
USER root
ARG CUBICWEB
RUN pip install "$CUBICWEB"
RUN apt-get update && apt-get -y --no-install-recommends install \
wget \
gnupg \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
ARG DIST
ARG COMPONENT
RUN echo "deb http://apt.logilab.fr $DIST $COMPONENT" > /etc/apt/sources.list.d/logilab.list
RUN wget -O - https://apt.logilab.fr/key.asc | apt-key --keyring /etc/apt/trusted.gpg.d/logilab.gpg add -
COPY --from=build /repo /repo
ARG PACKAGES
RUN apt-get update && apt-get -y --install-recommends install \
$PACKAGES \
&& rm -rf /var/lib/apt/lists/*
USER cubicweb
......@@ -42,7 +42,7 @@ def check_output(*args):
def _cwdev(_cache={}):
if not _cache:
rev = check_output('hg', 'id', '-r', 'default', CWREPO)
_cache[None] = '{}/archive/{}.tar.gz#egg=cubicweb[pyramid]'.format(
_cache[None] = '{}/archive/{}.tar.gz'.format(
CWREPO, rev)
return _cache[None]
......@@ -68,14 +68,6 @@ def tag_aliases():
check_call('docker', 'tag', src, tag)
def get_cubicweb_arg(cw):
return {
'3.25': 'cubicweb[pyramid]>=3.25,<3.26',
'3.26': 'cubicweb[pyramid]>=3.26,<3.27',
'dev': _cwdev(),
}[cw]
def build_image(python, dist, cw, onbuild, no_cache=False, registry=None):
tag = _tag(python, dist, cw, onbuild, registry=registry)
args = {}
......@@ -86,7 +78,13 @@ def build_image(python, dist, cw, onbuild, no_cache=False, registry=None):
elif cw is not None:
dockerfile = 'Dockerfile.cubicweb'
args['FROM'] = _tag(python, dist)
args['CUBICWEB'] = get_cubicweb_arg(cw)
args['DIST'] = dist
args['PACKAGES'] = 'python-cubicweb' if python == 'py27' else 'python3-cubicweb'
if cw == 'dev':
args['SOURCE_TARBALL'] = _cwdev()
args['COMPONENT'] = 'main'
else:
args['COMPONENT'] = 'cubicweb-{}'.format(cw)
else:
args['DIST'] = dist
args['PYTHON'] = 'python' if python == 'py27' else 'python3'
......@@ -127,7 +125,7 @@ def build(rebuild=False):
for matrix in MATRIX:
for python, dist, cw, onbuild in itertools.product(*matrix):
build_image(python, dist, cw, onbuild)
if rebuild and cw is None and onbuild is None:
if rebuild and onbuild is None:
tag = _tag(python, dist)
out = run(
'docker', 'run', '--rm', '-t',
......@@ -142,21 +140,6 @@ def build(rebuild=False):
else:
assert (out.returncode, out.stdout) == (0, b''), out
LOG.info(green('%s debian packages are up-to-date'), tag)
if rebuild and cw is not None and onbuild is None:
tag = _tag(python, dist, cw)
out = run(
'docker', 'run', '--rm', '-t',
'--user', 'root',
'--entrypoint', 'check-docker-updates.sh',
tag, 'pip', get_cubicweb_arg(cw))
if out.returncode == 1:
LOG.info(
red('%s python packages updates are available: %s'),
tag, out.stdout)
build_image(python, dist, cw, onbuild, no_cache=True)
else:
assert (out.returncode, out.stdout) == (0, b''), out
LOG.info(green('%s python packages are up-to-date'), tag)
def push():
......
#!/bin/sh
set -e
case "$1" in
apt)
apt-get update >/dev/null
apt list --upgradable 2>/dev/null | grep "upgradable from" && exit 1 || exit 0
;;
pip)
pip freeze > /tmp/freeze.txt
pip install --force-reinstall "$2" >/dev/null
pip freeze > /tmp/freeze.new.txt
diff -u /tmp/freeze.txt /tmp/freeze.new.txt
exit $?
;;
*)
echo "Usage: $0 apt|pip"
exit 64
;;
esac
apt-get update >/dev/null
apt list --upgradable 2>/dev/null | grep "upgradable from" && exit 1 || exit 0
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