Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
docker-cubicweb
Commits
c220f416812d
Commit
86ae456e
authored
Mar 12, 2021
by
Noé Gaumont
🐙
Browse files
feat various fix
parent
90250088b3bd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Dockerfile
View file @
c220f416
...
...
@@ -74,6 +74,6 @@ COPY --from=build /repo /repo
ARG
PACKAGES
RUN
apt-get update
&&
apt-get
-y
--install-recommends
install
\
$PACKAGES
\
&&
rm
-rf
/var/lib/apt/lists/
*
&&
rm
-rf
/var/lib/apt/lists/
*
\
&&
apt-mark hold
$PACKAGES
USER
cubicweb
Dockerfile.getversion
View file @
c220f416
ARG DIST
ARG PYTHON
FROM debian:$DIST-slim
RUN apt-get update && \
apt-get -y --no-install-recommends install \
wget \
gnupg \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
ARG DIST
RUN echo "deb http://apt.logilab.fr $DIST main" > /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 -
ARG PYTHON
ENV PYTHON=$PYTHON
CMD apt-get update > /dev/null && \
apt-cache show "$PYTHON"-cubicweb | grep '^Version' | cut -f2 -d' '
build.py
View file @
c220f416
...
...
@@ -5,7 +5,7 @@ import subprocess
import
sys
import
logging
from
dataclasses
import
dataclass
from
typing
import
Optional
from
typing
import
Optional
,
List
@
dataclass
class
CubicWebImage
:
...
...
@@ -22,11 +22,14 @@ class CubicWebImage:
def
cubicweb_major_version
(
self
):
return
self
.
cubicweb_version
.
rsplit
(
'.'
,
1
)[
0
]
def
__l
t
e__
(
self
,
other
):
def
__le__
(
self
,
other
):
lversion
=
self
.
cubicweb_version
.
split
(
"."
)
rversion
=
other
.
cubicweb_version
.
split
(
"."
)
return
lversion
<=
rversion
def
__gt__
(
self
,
other
):
return
not
self
<=
other
@
property
def
tag
(
self
):
if
self
.
package_version
==
'dev'
:
...
...
@@ -48,19 +51,19 @@ LOG = logging.getLogger(__name__)
REGISTRY
=
'logilab/cubicweb'
CWREPO
=
'https://forge.extranet.logilab.fr/cubicweb/cubicweb/'
MATRIX
=
[
([
'py27'
],
[
'stretch'
,
'buster'
],
[
None
,
'3.25'
,
'3.26'
],
[
None
,
'onbuild'
]),
([
'py35'
],
[
'stretch'
],
[
None
,
'3.26'
,
'3.27'
],
[
None
,
'onbuild'
]),
([
'py37'
],
[
'buster'
],
[
None
,
'3.26'
,
'3.27'
,
'3.28'
,
'3.29'
,
'dev
'
],
[
None
,
'onbuild'
]),
#
(['py27'], ['stretch', 'buster'], [None, '3.25', '3.26'],
#
[None, 'onbuild']),
#
(['py35'], ['stretch'], [None, '3.26', '3.27'], [None, 'onbuild']),
([
'py37'
],
[
'buster'
],
[
'3.29
'
],
[
None
,
'onbuild'
]),
]
ALIASES
=
(
(
'3.25'
,
'py27-buster-3.25'
),
(
'3.26'
,
'py37-buster-3.26'
),
(
'3.27'
,
'py37-buster-3.27'
),
(
'3.28'
,
'py37-buster-3.28'
),
#
('3.25', 'py27-buster-3.25'),
#
('3.26', 'py37-buster-3.26'),
#
('3.27', 'py37-buster-3.27'),
#
('3.28', 'py37-buster-3.28'),
(
'3.29'
,
'py37-buster-3.29'
),
(
'dev'
,
'py37-buster-dev'
),
(
'latest'
,
'py37-buster-3.29'
),
#
('dev', 'py37-buster-dev'),
#
('latest', 'py37-buster-3.29'),
(
'buildpackage'
,
'buster-buildpackage'
),
)
...
...
@@ -88,8 +91,7 @@ def _cwdev(_cache={}):
CWREPO
,
rev
)
return
_cache
[
None
]
def
tag_aliases
(
images
:
list
[
CubicWebImage
]):
def
get_major_tags
(
images
:
List
[
CubicWebImage
]):
latest
=
{}
for
cwimage
in
[
img
for
img
in
images
if
img
.
package_version
!=
'dev'
]:
version
=
cwimage
.
cubicweb_major_version
...
...
@@ -99,8 +101,13 @@ def tag_aliases(images: list[CubicWebImage]):
if
latest
[
version
]
<=
cwimage
:
latest
[
version
]
=
cwimage
last_major
=
max
(
latest
.
values
())
latest
[
'latest'
]
=
last_major
return
latest
def
tag_aliases
(
images
:
List
[
CubicWebImage
],
last_debian_dist
:
str
):
latest
=
get_major_tags
(
images
)
for
major
,
img
in
(
*
latest
.
items
()
,
(
'latest'
,
last_major
))
:
for
major
,
img
in
latest
.
items
():
tag
=
f
"
{
REGISTRY
}
:
{
major
}
"
for
onbuild
in
[
None
,
'onbuild'
]:
if
onbuild
==
'onbuild'
:
...
...
@@ -110,9 +117,8 @@ def tag_aliases(images: list[CubicWebImage]):
src
=
img
.
tag
check_call
(
'docker'
,
'tag'
,
src
,
tag
)
check_call
(
'docker'
,
'tag'
,
src
,
img
.
major_tag
)
if
major
==
'buildpackage'
:
check_call
(
'docker'
,
'tag'
,
img
.
tag
,
f
"
{
REGISTRY
}
:
{
major
}
"
)
continue
check_call
(
'docker'
,
'tag'
,
f
'
{
REGISTRY
}
:
{
last_debian_dist
}
-buildpackage'
,
f
"
{
REGISTRY
}
:buildpackage"
)
def
build_image
(
image
:
CubicWebImage
,
onbuild
:
Optional
[
str
],
no_cache
=
False
,
registry
=
None
):
...
...
@@ -125,13 +131,13 @@ def build_image(image: CubicWebImage, onbuild: Optional[str], no_cache=False, re
else
:
args
[
'PYTHON'
]
=
'python'
if
image
.
python
==
'py27'
else
'python3'
dockerfile
=
'Dockerfile'
args
[
'FROM'
]
=
image
.
base_docker_image
args
[
'DIST'
]
=
image
.
debian
args
[
'PACKAGES'
]
=
f
"
{
image
.
package_name
}
=
{
image
.
package_version
}
"
tag
=
image
.
tag
if
image
.
package_version
==
'dev'
:
args
[
'SOURCE_TARBALL'
]
=
_cwdev
()
args
[
'COMPONENT'
]
=
'main'
args
[
'PACKAGES'
]
=
f
"
{
image
.
package_name
}
"
else
:
args
[
'COMPONENT'
]
=
'cubicweb-{}'
.
format
(
image
.
cubicweb_major_version
)
...
...
@@ -161,7 +167,7 @@ def build_buildpackage(dist):
'--build-arg'
,
'DIST={}'
.
format
(
dist
),
'-f'
,
'Dockerfile.buildpackage'
,
'.'
)
def
get_cubicweb_images
(
debian_dists
:
l
ist
[
str
],
python_versions
:
l
ist
[
str
]):
def
get_cubicweb_images
(
debian_dists
:
L
ist
[
str
],
python_versions
:
L
ist
[
str
]):
images
=
[]
for
dist
in
debian_dists
:
for
python_version
in
python_versions
:
...
...
@@ -197,7 +203,7 @@ def get_cubicweb_images(debian_dists: list[str], python_versions: list[str]):
images
.
append
(
image
)
return
images
def
build
(
debian_dists
,
images
=
[],
rebuild
=
False
):
def
build
(
debian_dists
:
List
[
str
],
images
:
List
[
CubicWebImage
]
=
[],
rebuild
=
False
):
for
dist
in
debian_dists
:
if
rebuild
:
# pull base images
...
...
@@ -224,22 +230,23 @@ def build(debian_dists, images=[], rebuild=False):
LOG
.
info
(
green
(
'%s debian packages are up-to-date'
),
tag
)
def
push
():
for
matrix
in
MATRIX
:
for
python
,
dist
,
cw
,
onbuild
in
itertools
.
product
(
*
matrix
):
tag
=
_tag
(
python
,
dist
,
cw
,
onbuild
)
check_call
(
'docker'
,
'push'
,
tag
)
for
alias
,
source
in
ALIASES
:
if
alias
==
"buildpackage"
:
check_call
(
'docker'
,
'push'
,
_tag
(
source
))
check_call
(
'docker'
,
'push'
,
_tag
(
alias
))
continue
def
push
(
images
:
List
[
CubicWebImage
],
last_debian_dist
:
str
):
latest
=
get_major_tags
(
images
)
for
image
in
images
:
check_call
(
'docker'
,
'push'
,
image
.
tag
)
for
major
,
img
in
latest
.
items
():
tag
=
f
"
{
REGISTRY
}
:
{
major
}
"
for
onbuild
in
[
None
,
'onbuild'
]:
if
alias
==
'latest'
and
onbuild
==
'onbuild'
:
tag
=
_tag
(
'
onbuild
'
)
if
onbuild
==
'onbuild'
:
tag
=
f
"
{
REGISTRY
}
:
{
major
}
-
{
onbuild
}
"
else
:
tag
=
_tag
(
alias
,
onbuild
)
check_call
(
'docker'
,
'push'
,
tag
)
tag
=
f
"
{
REGISTRY
}
:
{
major
}
"
src
=
img
.
tag
check_call
(
'docker'
,
'push'
,
major
)
check_call
(
'docker'
,
'push'
,
img
.
major_tag
)
check_call
(
'docker'
,
'push'
,
f
'
{
REGISTRY
}
:
{
last_debian_dist
}
-buildpackage'
,
f
"
{
REGISTRY
}
:buildpackage"
)
if
__name__
==
'__main__'
:
...
...
@@ -263,7 +270,7 @@ if __name__ == '__main__':
CubicWebImage
(
"py37"
,
"buster"
,
"python3-cubicweb"
,
"dev"
)
)
if
args
.
push
:
push
()
push
(
images
=
images
,
last_debian_dist
=
"buster"
)
else
:
build
(
images
=
images
,
rebuild
=
args
.
checkrebuild
)
tag_aliases
(
images
)
build
(
debian_dists
=
[
"stretch"
,
"buster"
],
images
=
images
,
rebuild
=
args
.
checkrebuild
)
tag_aliases
(
images
=
images
,
last_debian_dist
=
"buster"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment