dkbuild: implémentation initiale

This commit is contained in:
Jephté Clain 2022-03-29 09:42:27 +04:00
parent f46812f07a
commit f7ab14ff7e
45 changed files with 3197 additions and 0 deletions

View File

@ -1,3 +1,6 @@
# TODO
dkbuild
* commande 'mvn'
-*- coding: utf-8 mode: markdown -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8:noeol:binary

2761
dkbuild Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
php

View File

@ -0,0 +1,3 @@
*.zip filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.tar.gz filter=lfs diff=lfs merge=lfs -text

View File

@ -0,0 +1,2 @@
.~lock*#
.*.swp

View File

@ -0,0 +1,2 @@
/b/t/
**/.git/

View File

@ -0,0 +1,3 @@
/b/
/Dockerfile
# autogénéré

View File

@ -0,0 +1,11 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
setdists d10
# fichiers communs
copy ../common/ ./ gitignore=.
dockerfile
# -*- coding: utf-8 mode: dockerfile -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
FROM $REGISTRY/debian/min:$DIST
#RUN /debian/pkg i
build

View File

@ -0,0 +1 @@
../dkbuild.env

View File

@ -0,0 +1,2 @@
/b/t/
**/.git/

View File

@ -0,0 +1,3 @@
/b/
/Dockerfile
# autogénéré

View File

@ -0,0 +1,11 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
setdists d11
# fichiers communs
copy ../common/ ./ gitignore=.
dockerfile
# -*- coding: utf-8 mode: dockerfile -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
FROM $REGISTRY/debian/min:$DIST
#RUN /debian/pkg i
build

View File

@ -0,0 +1 @@
../dkbuild.env

View File

@ -0,0 +1,2 @@
/b/t/
**/.git/

View File

@ -0,0 +1,3 @@
/b/
/Dockerfile
# autogénéré

View File

@ -0,0 +1,11 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
setdists d9
# fichiers communs
copy ../common/ ./ gitignore=.
dockerfile
# -*- coding: utf-8 mode: dockerfile -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
FROM $REGISTRY/debian/min:$DIST
#RUN /debian/pkg i
build

View File

@ -0,0 +1 @@
../dkbuild.env

View File

@ -0,0 +1,15 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
dists=(
d11
d10
#d9
)
setdists "${dists[@]}"
if dist d11; then
include d11
elif dist d10; then
include d10
elif dist d9; then
include d9
fi

View File

@ -0,0 +1,3 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
setenv REGISTRY=docker.univ-reunion.fr
setenv IMAGE=$REGISTRY/GROUP/NAME

3
lib/dkbuild/templates/php/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/Dockerfile
.~lock*#
.*.swp

View File

@ -0,0 +1,27 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
setenv DIST=d11
if profile prod; then
default checkout branch=master
elif profile test devel; then
default checkout branch=develop
fi
default composer image=$REGISTRY/image/phpbuilder:$DIST
## web ########################################################################
checkout https://git.univ-reunion.fr/sda-php/NAME-app b/web
composer b/web
dockerfile
# -*- coding: utf-8 mode: dockerfile -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
FROM $REGISTRY/image/apache-php-myiccas:$DIST
#RUN /debian/pkg i
#ENV MSMTP_ENABLE=1
#COPY b/web/config/msmtp /msmtp-config
COPY b/web/config/ssl /ssl-config
COPY b/web/config/apache /apache-config
COPY b/web/config/php /php-config
#COPY b/web/config/before-start-apache /
COPY b/web /var/www/app
build

View File

@ -0,0 +1,3 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
setenv REGISTRY=docker.univ-reunion.fr
setenv IMAGE=$REGISTRY/GROUP/NAME

View File

@ -0,0 +1,6 @@
/docker-compose.yml
/docker-compose.*.yml
/web/Dockerfile
/db/Dockerfile
.~lock*#
.*.swp

View File

@ -0,0 +1,37 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
setprofiles prod test devel
if profile prod; then
default checkout branch=master
elif profile test devel; then
default checkout branch=develop
fi
default composer image=$REGISTRY/image/phpbuilder:$DIST
## web ########################################################################
checkout https://git.univ-reunion.fr/sda-php/NAME-app web/b/web
composer web/b/web
dockerfile context=web
# -*- coding: utf-8 mode: dockerfile -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
FROM $REGISTRY/image/apache-php-myiccas:$DIST
#RUN /debian/pkg i
#ENV MSMTP_ENABLE=1
#COPY b/web/config/msmtp /msmtp-config
COPY b/web/config/ssl /ssl-config
COPY b/web/config/apache /apache-config
COPY b/web/config/php /php-config
#COPY b/web/config/before-start-apache /
COPY b/web /var/www/app
## db #########################################################################
copy web/b/web/config/sqlmig db/config/mariadb/sqlmig
dockerfile context=db
# -*- coding: utf-8 mode: dockerfile -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
FROM $REGISTRY/image/mariadb:$DIST
COPY config/mariadb /mariadb-config

View File

@ -0,0 +1,4 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
setenv REGISTRY=docker.univ-reunion.fr
setenv IMAGE=$REGISTRY/GROUP/NAME
setenv DIST=d11

View File

@ -0,0 +1,12 @@
# -*- coding: utf-8 mode: yaml -*- vim:sw=2:sts=2:et:ai:si:sta:fenc=utf-8
version: "3.7"
services:
db:
image: $REGISTRY/devel/GROUP/NAME-db
web:
image: $REGISTRY/devel/GROUP/NAME-web
environment:
- APP_PROFILE=devel
- BASE_URL=http://NAME.self

View File

@ -0,0 +1,14 @@
# -*- coding: utf-8 mode: yaml -*- vim:sw=2:sts=2:et:ai:si:sta:fenc=utf-8
version: "3.7"
services:
db:
image: $REGISTRY/GROUP/NAME-db
web:
image: $REGISTRY/GROUP/NAME-web
environment:
- APP_PROFILE=prod
- BASE_URL=https://NAME.univ-reunion.fr
extra_hosts:
- "casn.univ-reunion.fr:10.85.1.15"

View File

@ -0,0 +1,14 @@
# -*- coding: utf-8 mode: yaml -*- vim:sw=2:sts=2:et:ai:si:sta:fenc=utf-8
version: "3.7"
services:
db:
image: $REGISTRY/test/GROUP/NAME-db
web:
image: $REGISTRY/test/GROUP/NAME-web
environment:
- APP_PROFILE=test
- BASE_URL=https://NAME-test.univ-reunion.fr
extra_hosts:
- "casn.univ-reunion.fr:10.85.1.15"

View File

@ -0,0 +1,34 @@
# -*- coding: utf-8 mode: yaml -*- vim:sw=2:sts=2:et:ai:si:sta:fenc=utf-8
version: "3.7"
services:
db:
build: db
volumes:
- db-data:/var/lib/mysql
networks:
default:
aliases:
- NAMEdb
deploy:
update_config:
order: stop-first
web:
build: web
volumes:
- log-data:/var/log/apache2
- session-data:/var/lib/php/sessions
extra_hosts:
- "smtp.univ.run:10.82.70.46"
- "vs-apoprod-bdd.univ.run:10.82.91.11"
- "vs-apotest-bdd.univ.run:10.82.91.13"
- "vs-apodevp-bdd.univ.run:10.82.91.15"
deploy:
update_config:
order: start-first
volumes:
db-data:
log-data:
session-data:

View File

@ -0,0 +1,8 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
# Description des templates de ce répertoire
TEMPLATES=(
[image]="Image générique basée sur debian"
[php]="Application web PHP"
[php_db]="Application web PHP avec base de données"
)

5
lib/dkbuild/tests/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
/Dockerfile
/src
/dest
/srcdir/
/destdir/

View File

@ -0,0 +1,2 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
setenv REGISTRY=jclain.fr

View File

@ -0,0 +1,16 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
section "variables de build"
setarg A="arg A"
resetarg B="arg B"
info "A=${ARGS[A]}, B=${ARGS[B]}"
if [ "${ARGS[A]}" != x ]; then
note "\
Essayer de relancer avec
$(qvals dkbuild -j "$(relpath "$DKBUILD")" --arg A=x --arg B=y)
on ne devrait pas pouvoir modifier la valeur de B"
fi
# pas de build automatique
AUTOBUILD=

View File

@ -0,0 +1,13 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
setenv REGISTRY=docker.univ-reunion.fr
setenv IMAGE=$REGISTRY/group/name
info "IMAGE=$IMAGE"
if [ "$REGISTRY" == docker.univ-reunion.fr ]; then
note "\
Essayer de relancer avec
$(qvals dkbuild -j "$(relpath "$DKBUILD")" -c registry.env)
La valeur de IMAGE devrait changer"
fi
AUTOBUILD=

View File

@ -0,0 +1,15 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
run rm -rf src dest srcdir destdir
run mkdir srcdir
genfile srcdir/src <<<"file"
run ln -s src srcdir/link
copy srcdir destdir
if run; then
[ -f destdir/src ] || die "destdir/src n'a pas été créé"
diff -qr srcdir destdir || die "srcdir et destdir ne sont pas identiques"
fi
AUTOBUILD=

View File

@ -0,0 +1,13 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
run rm -rf src dest srcdir destdir
run mkdir srcdir
genfile srcdir/src <<<"file"
run ln -s src srcdir/link
genfile dest <<<"dest"
copy srcdir dest
info "on ne devrait pas arriver ici"
AUTOBUILD=

View File

@ -0,0 +1,13 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
setdists d11 d10
setprofiles prod test
if dist "#latest"; then
info "$DIST est la distribution la plus récente"
fi
if profile "#default"; then
info "$PROFILE est le profil par défaut"
fi
# pas de build automatique
AUTOBUILD=

View File

@ -0,0 +1,14 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
run rm -rf src dest srcdir destdir
genfile src <<<"file"
run mkdir destdir
copy src destdir
if run; then
[ -f destdir/src ] || die "destdir/src n'a pas été créé"
diff -q src destdir/src || die "src et destdir/src ne sont pas identiques"
fi
AUTOBUILD=

View File

@ -0,0 +1,13 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
run rm -rf src dest srcdir destdir
genfile src <<<"file"
copy src dest
if run; then
[ -f dest ] || die "dest n'a pas été créé"
diff -q src dest || die "src et dest ne sont pas identiques"
fi
AUTOBUILD=

View File

@ -0,0 +1,27 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
run rm -rf src dest srcdir destdir
run mkdir srcdir
genfile srcdir/src <<<"file"
run ln -s src srcdir/link
run mkdir destdir
genfile destdir/.gitignore <<<"/a/"
copy srcdir destdir/a gitignore=destdir
copy srcdir destdir/b gitignore=destdir
if run; then
[ -f destdir/a/src ] || die "destdir/a/src n'a pas été créé"
[ -f destdir/b/src ] || die "destdir/b/src n'a pas été créé"
[ -L destdir/a/link ] || die "destdir/a/link n'a pas été créé"
[ -L destdir/b/link ] || die "destdir/b/link n'a pas été créé"
ignored="$(<destdir/.gitignore)"
expected="\
/a/
/b/link
/b/src"
[ "$ignored" == "$expected" ] || die "les fichiers n'ont pas été ignorés"
fi
AUTOBUILD=

View File

@ -0,0 +1,16 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
if machine fast5; then
setprofiles prod
elif machine fast4; then
setprofiles test
else
setprofiles devel test prod
fi
if run; then
echo "PROFILE=$PROFILE"
fi
# pas de build automatique
AUTOBUILD=

View File

@ -0,0 +1,16 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
section "première section"
note "une note"
info "une première info"
info "une deuxième info"
debug "message de debug"
section "deuxième section"
note "une note"
info "une première info"
info "une deuxième info"
debug "message de debug"
# pas de build automatique
AUTOBUILD=

View File

@ -0,0 +1,8 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
setenv IMAGE=dkbuild-tests/tags0
dockerfile
# -*- coding: utf-8 mode: dockerfile -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
FROM scratch
ENV var=empty
build

View File

@ -0,0 +1,9 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
setprofiles v1-prod v2-prod
setenv IMAGE=dkbuild-tests/tags1
dockerfile
# -*- coding: utf-8 mode: dockerfile -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
FROM scratch
ENV var=empty
build

View File

@ -0,0 +1,16 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
section "variables d'environnement"
setenv A="env A"
resetenv B="env B"
info "A=$A, B=$B"
if [ "$A" != x ]; then
note "\
Essayer de relancer avec
$(qvals dkbuild -j "$(relpath "$DKBUILD")" -e A=x -e B=y)
on ne devrait pas pouvoir modifier la valeur de B"
fi
# pas de build automatique
AUTOBUILD=