support build local et build flavour

This commit is contained in:
Jephté Clain 2024-05-15 16:23:53 +04:00
parent 44e0a784ca
commit 42253c963e
10 changed files with 179 additions and 30 deletions

View File

@ -7,21 +7,21 @@ FROM $REGISTRY/src/php as php
################################################################################
FROM debian:${NDIST}-slim as builder
COPY --from=base /g/ /g/
COPY --from=base /src/ /src/
ARG APT_MIRROR SEC_MIRROR APT_PROXY TIMEZONE
ENV APT_MIRROR=$APT_MIRROR SEC_MIRROR=$SEC_MIRROR APT_PROXY=$APT_PROXY TIMEZONE=$TIMEZONE
COPY --from=base /g/ /g/
COPY --from=base /src/ /src/
RUN /g/build core lite _builder
RUN make -C /src/su-exec
RUN /g/build _su-exec_builder
################################################################################
FROM debian:${NDIST}-slim
COPY --from=builder /src/su-exec/su-exec /g/
COPY --from=base /g/ /g/
ARG APT_MIRROR SEC_MIRROR APT_PROXY TIMEZONE
ENV APT_MIRROR=$APT_MIRROR SEC_MIRROR=$SEC_MIRROR APT_PROXY=$APT_PROXY TIMEZONE=$TIMEZONE
COPY --from=base /g/ /g/
COPY --from=builder /src/su-exec/su-exec /g/
RUN /g/build
COPY --from=php /g/ /g/

43
support/Dockerfile.cli+ic Normal file
View File

@ -0,0 +1,43 @@
# -*- coding: utf-8 mode: dockerfile -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
ARG NDIST=12
ARG REGISTRY=pubdocker.univ-reunion.fr
FROM $REGISTRY/src/base as base
FROM $REGISTRY/src/instantclient as instantclient
FROM $REGISTRY/src/php as php
FROM $REGISTRY/src/nutools as nutools
################################################################################
FROM debian:${NDIST}-slim as builder
ARG APT_MIRROR SEC_MIRROR APT_PROXY TIMEZONE
ENV APT_MIRROR=$APT_MIRROR SEC_MIRROR=$SEC_MIRROR APT_PROXY=$APT_PROXY TIMEZONE=$TIMEZONE
COPY --from=base /g/ /g/
COPY --from=base /src/ /src/
RUN /g/build core lite _builder
RUN /g/build _su-exec_builder
COPY --from=instantclient /g/ /g/
COPY --from=instantclient /src/ /src/
RUN /g/build _instantclient_builder
################################################################################
FROM debian:${NDIST}-slim
ARG APT_MIRROR SEC_MIRROR APT_PROXY TIMEZONE
ENV APT_MIRROR=$APT_MIRROR SEC_MIRROR=$SEC_MIRROR APT_PROXY=$APT_PROXY TIMEZONE=$TIMEZONE
COPY --from=base /g/ /g/
COPY --from=builder /src/su-exec/su-exec /g/
RUN /g/build
COPY --from=php /g/ /g/
RUN /g/build @php-cli php-utils
COPY --from=instantclient /g/ /g/
COPY --from=builder /opt/oracle/ /opt/oracle/
RUN /g/build instantclient
COPY --from=nutools /g/ /g/
RUN /g/build nutools
ENTRYPOINT ["/g/entrypoint"]

View File

@ -4,11 +4,11 @@ FROM $REGISTRY/src/base as base
FROM $REGISTRY/src/mariadb as mariadb
FROM mariadb:10
ARG APT_PROXY TIMEZONE
ENV APT_PROXY=$APT_PROXY TIMEZONE=$TIMEZONE
COPY --from=base /g/ /g/
COPY --from=mariadb /g/ /g/
ARG APT_PROXY TIMEZONE
ENV APT_PROXY=$APT_PROXY TIMEZONE=$TIMEZONE
RUN /g/build -a @base @mariadb
EXPOSE 3306

View File

@ -7,21 +7,21 @@ FROM $REGISTRY/src/php as php
################################################################################
FROM debian:${NDIST}-slim as builder
COPY --from=base /g/ /g/
COPY --from=base /src/ /src/
ARG APT_MIRROR SEC_MIRROR APT_PROXY TIMEZONE
ENV APT_MIRROR=$APT_MIRROR SEC_MIRROR=$SEC_MIRROR APT_PROXY=$APT_PROXY TIMEZONE=$TIMEZONE
COPY --from=base /g/ /g/
COPY --from=base /src/ /src/
RUN /g/build core lite _builder
RUN make -C /src/su-exec
RUN /g/build _su-exec_builder
################################################################################
FROM debian:${NDIST}-slim
COPY --from=builder /src/su-exec/su-exec /g/
COPY --from=base /g/ /g/
ARG APT_MIRROR SEC_MIRROR APT_PROXY TIMEZONE
ENV APT_MIRROR=$APT_MIRROR SEC_MIRROR=$SEC_MIRROR APT_PROXY=$APT_PROXY TIMEZONE=$TIMEZONE
COPY --from=base /g/ /g/
COPY --from=builder /src/su-exec/su-exec /g/
RUN /g/build
COPY --from=php /g/ /g/

View File

@ -0,0 +1,43 @@
# -*- coding: utf-8 mode: dockerfile -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
ARG NDIST=12
ARG REGISTRY=pubdocker.univ-reunion.fr
FROM $REGISTRY/src/base as base
FROM $REGISTRY/src/instantclient as instantclient
FROM $REGISTRY/src/php as php
FROM $REGISTRY/src/nutools as nutools
################################################################################
FROM debian:${NDIST}-slim as builder
ARG APT_MIRROR SEC_MIRROR APT_PROXY TIMEZONE
ENV APT_MIRROR=$APT_MIRROR SEC_MIRROR=$SEC_MIRROR APT_PROXY=$APT_PROXY TIMEZONE=$TIMEZONE
COPY --from=base /g/ /g/
COPY --from=base /src/ /src/
RUN /g/build core lite _builder
RUN /g/build _su-exec_builder
COPY --from=instantclient /g/ /g/
COPY --from=instantclient /src/ /src/
RUN /g/build _instantclient_builder
################################################################################
FROM debian:${NDIST}-slim
ARG APT_MIRROR SEC_MIRROR APT_PROXY TIMEZONE
ENV APT_MIRROR=$APT_MIRROR SEC_MIRROR=$SEC_MIRROR APT_PROXY=$APT_PROXY TIMEZONE=$TIMEZONE
COPY --from=base /g/ /g/
COPY --from=builder /src/su-exec/su-exec /g/
RUN /g/build
COPY --from=php /g/ /g/
RUN /g/build @php-cli php-utils
COPY --from=instantclient /g/ /g/
COPY --from=builder /opt/oracle/ /opt/oracle/
RUN /g/build instantclient
COPY --from=nutools /g/ /g/
RUN /g/build nutools
ENTRYPOINT ["/g/entrypoint"]

View File

@ -7,25 +7,25 @@ FROM $REGISTRY/src/php as php
################################################################################
FROM debian:${NDIST}-slim as builder
COPY --from=base /g/ /g/
COPY --from=base /src/ /src/
ARG APT_MIRROR SEC_MIRROR APT_PROXY TIMEZONE
ENV APT_MIRROR=$APT_MIRROR SEC_MIRROR=$SEC_MIRROR APT_PROXY=$APT_PROXY TIMEZONE=$TIMEZONE
COPY --from=base /g/ /g/
COPY --from=base /src/ /src/
RUN /g/build core lite _builder
RUN make -C /src/su-exec
RUN /g/build _su-exec_builder
################################################################################
FROM debian:${NDIST}-slim
COPY --from=builder /src/su-exec/su-exec /g/
COPY --from=base /g/ /g/
ARG APT_MIRROR SEC_MIRROR APT_PROXY TIMEZONE
ENV APT_MIRROR=$APT_MIRROR SEC_MIRROR=$SEC_MIRROR APT_PROXY=$APT_PROXY TIMEZONE=$TIMEZONE
COPY --from=base /g/ /g/
COPY --from=builder /src/su-exec/su-exec /g/
RUN /g/build
COPY --from=php /g/ /g/
RUN /g/build -a @apache-php-cas php-utils
EXPOSE 80
EXPOSE 80 443
ENTRYPOINT ["/g/entrypoint"]

44
support/Dockerfile.web+ic Normal file
View File

@ -0,0 +1,44 @@
# -*- coding: utf-8 mode: dockerfile -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
ARG NDIST=12
ARG REGISTRY=pubdocker.univ-reunion.fr
FROM $REGISTRY/src/base as base
FROM $REGISTRY/src/instantclient as instantclient
FROM $REGISTRY/src/php as php
FROM $REGISTRY/src/nutools as nutools
################################################################################
FROM debian:${NDIST}-slim as builder
ARG APT_MIRROR SEC_MIRROR APT_PROXY TIMEZONE
ENV APT_MIRROR=$APT_MIRROR SEC_MIRROR=$SEC_MIRROR APT_PROXY=$APT_PROXY TIMEZONE=$TIMEZONE
COPY --from=base /g/ /g/
COPY --from=base /src/ /src/
RUN /g/build core lite _builder
RUN /g/build _su-exec_builder
COPY --from=instantclient /g/ /g/
COPY --from=instantclient /src/ /src/
RUN /g/build _instantclient_builder
################################################################################
FROM debian:${NDIST}-slim
ARG APT_MIRROR SEC_MIRROR APT_PROXY TIMEZONE
ENV APT_MIRROR=$APT_MIRROR SEC_MIRROR=$SEC_MIRROR APT_PROXY=$APT_PROXY TIMEZONE=$TIMEZONE
COPY --from=base /g/ /g/
COPY --from=builder /src/su-exec/su-exec /g/
RUN /g/build
COPY --from=php /g/ /g/
RUN /g/build -a @apache-php-cas php-utils
COPY --from=instantclient /g/ /g/
COPY --from=builder /opt/oracle/ /opt/oracle/
RUN /g/build instantclient
COPY --from=nutools /g/ /g/
RUN /g/build nutools
EXPOSE 80 443
ENTRYPOINT ["/g/entrypoint"]

View File

@ -2,7 +2,8 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
MYDIR="$(cd "$(dirname -- "$0")"; pwd)"
"$MYDIR/rundk" --bs --ue --ci || exit 1
PROJDIR=; COMPOSERDIR=; COMPOSERPHAR=; VENDORDIR=; BUILDENV0=; BUILDENV=; DIST=; IMAGENAME=; BUILD_IMAGES=(web db)
PROJDIR=; COMPOSERDIR=; COMPOSERPHAR=; VENDORDIR=; BUILDENV0=; BUILDENV=; BUILD_IMAGES=(web db); BUILD_FLAVOUR=; DIST=; IMAGENAME=
export BUILD_FLAVOUR
source "$MYDIR/rundk" || exit 1
source "$PROJDIR/$VENDORDIR/nulib/php/load.sh" || exit 1
require: template
@ -68,10 +69,16 @@ function _build() {
local dockerfile image="${PRIVAREG:+$PRIVAREG/}${IMAGENAME%/*}/$1"
if [ -n "$ForceBuild" -o -z "$(dklsimg "$image")" ]; then
estep "Construction de $image"
if [ -f "$PROJDIR/Dockerfile.$1" ]; then dockerfile="$PROJDIR/Dockerfile.$1"
elif [ -f "$MYDIR/Dockerfile.$1" ]; then dockerfile="$MYDIR/Dockerfile.$1"
else dockerfile="$PROJDIR/$VENDORDIR/nulib/php/support/Dockerfile.$1"
fi
dockerfiles=(
"$MYDIR/Dockerfile.$1.local"
"$MYDIR/Dockerfile.$1$BUILD_FLAVOUR"
"$PROJDIR/$VENDORDIR/nulib/php/support/Dockerfile.$1$BUILD_FLAVOUR"
"$MYDIR/Dockerfile.$1"
"$PROJDIR/$VENDORDIR/nulib/php/support/Dockerfile.$1"
)
for dockerfile in "${dockerfiles[@]}"; do
[ -f "$dockerfile" ] && break
done
args=(
-f "$dockerfile"
${Pull:+--pull}

View File

@ -17,6 +17,9 @@ else
MYDIR="$(cd "$(dirname -- "$0")"; pwd)"
MYNAME="$(basename -- "$0")"
fi
if [ -f "$MYDIR/rundk.userconf.local" ]; then
source "$MYDIR/rundk.userconf.local"
fi
[ -n "$PROJDIR" ] || PROJDIR="$(dirname -- "$MYDIR")"
[ "${PROJDIR#/}" != "$PROJDIR" ] || PROJDIR="$(cd "$MYDIR/$PROJDIR"; pwd)"
@ -291,8 +294,16 @@ OPTIONS
fi
if [ -z "$UnlessExists" -o -z "$(docker image ls --no-trunc --format '{{.Repository}}:{{.Tag}}' "$IMAGE" 2>/dev/null)" ]; then
eecho "== Building $IMAGE"
dockerfiles=(
"$MYDIR/Dockerfile.rundk.local"
"$MYDIR/Dockerfile.rundk$BUILD_FLAVOUR"
"$MYDIR/Dockerfile.rundk"
)
for dockerfile in "${dockerfiles[@]}"; do
[ -f "$dockerfile" ] && break
done
args=(
-f "$MYDIR/Dockerfile.rundk"
-f "$dockerfile"
${Pull:+--pull}
${NoCache:+--no-cache}
${BuildPlain:+--progress plain}

View File

@ -15,6 +15,7 @@ BUILDENV=
# Listes des images que le script build construit automatiquement
BUILD_IMAGES=(web db)
BUILD_FLAVOUR=
## En ce qui concerne DIST et IMAGENAME, les valeurs dans BUILDENV prennent le
## dessus. si BUILDENV *n'est pas* utilisé, ces valeur peuvent être spécifiées