Browse Source

new: image update is now available for charms

hostresources
Valentin Lab 6 years ago
parent
commit
dd8ff92c63
  1. 8
      Dockerfile
  2. 56
      bin/compose-core

8
Dockerfile

@ -17,6 +17,7 @@ ENV KAL_SHLIB_ARRAY_VERSION="0.2.0" \
KAL_SHLIB_CONFIG_VERSION="0.0.2" \
KAL_SHLIB_CORE_VERSION="0.7.0" \
KAL_SHLIB_FIREWALL_VERSION="0.2.0" \
KAL_SHLIB_DOCKER_VERSION="0.0.1" \
KAL_SHLIB_OTHER_VERSION="0.2.2" \
KAL_SHLIB_PRETTY_VERSION="0.4.3"
@ -41,7 +42,7 @@ RUN mkdir -p /tmp/docker \
RUN apk --update add binutils && \
mkdir /tmp/kal-shlibs && cd /tmp/kal-shlibs && \
export pkg && \
for pkg in core common array cache charm cmdline config firewall other pretty; do \
for pkg in core common array cache charm cmdline config firewall other pretty docker; do \
echo "Installing kal-shlib-$pkg" ; \
bash -c -- 'eval curl -L http://deb.kalysto.org/pool/no-dist/kal-alpha/kal-shlib-${pkg}_\${KAL_SHLIB_${pkg^^}_VERSION}-1_all.deb' > pkg.deb || exit 1 ; \
ar x pkg.deb || exit 1; \
@ -65,6 +66,10 @@ RUN curl -L https://git.0k.io/0k-charm.git/plain/bin/charm > /usr/local/bin/char
RUN curl -L https://git.0k.io/git-sub.git/plain/bin/git-sub > /usr/local/bin/git-sub && \
chmod +x /usr/local/bin/git-sub
RUN curl -L https://git.0k.io/0k-docker.git/plain/src/bin/dupd > /usr/local/bin/dupd && \
chmod +x /usr/local/bin/dupd
RUN curl http://docker.0k.io/get/ca.0k.io.pem > /usr/local/share/ca-certificates/ca.0k.io.pem
##force install pyyaml with libyaml
@ -79,6 +84,7 @@ RUN cd /tmp && \
FROM common
COPY --from=builder /etc/shlib /etc/shlib
COPY --from=builder /usr/bin/bash-shlib /usr/bin/bash-shlib
COPY --from=builder /usr/lib/shlib /usr/lib/shlib
COPY --from=builder /usr/local /usr/local

56
bin/compose-core

@ -352,14 +352,9 @@ export -f docker_has_image
docker_image_id() {
local image="$1" image_id cache_file="$state_dir/$FUNCNAME.cache.$(echo "$*" | md5_compat)"
if [ -e "$cache_file" ]; then
# debug "$FUNCNAME: cache hit ($*)"
quick_cat_stdin < "$cache_file"
return 0
fi
local image="$1"
image_id=$(docker inspect "$image" --format='{{.Id}}') || return 1
echo "$image_id" | tee "$cache_file"
echo "$image_id" # | tee "$cache_file"
}
export -f docker_image_id
@ -407,6 +402,53 @@ cached_cmd_on_base_image() {
export -f cached_cmd_on_base_image
docker_update() {
## YYY: warning, we a storing important information in cache, cache can
## be removed.
## We want here to cache the last script on given service whatever that script was
local service="$1" script="$2" cache_file="$CACHEDIR/$FUNCNAME.cache.$1" \
previous_base_image stored_image_id
shift
shift
## this will build it if necessary
base_image=$(service_base_docker_image "$service") || return 1
## XXXvlab: there are probably ways to avoid rebuilding that each time
image_id="$(docker_image_id "$base_image")" || return 1
if [ -e "$cache_file" ]; then
info "Cache file exists"
read-0 previous_base_image stored_image_id < <(cat "$cache_file")
info "previous: $previous_base_image"
info "stored: $stored_image_id"
else
info "No cache file $cache_file"
previous_base_image=""
fi
if [ "$previous_base_image" -a "$stored_image_id" == "$image_id" ]; then
info "Resetting $base_image to $previous_base_image"
docker tag "$previous_base_image" "$base_image" || return 1
image_id="$(docker_image_id "$base_image")" || return 1
else
previous_base_image="$image_id"
fi
info "Updating base image: $base_image (hash: $image_id)"
echo "$script" | dupd --debug -u "$base_image" -- "$@" || {
err "Failed updating base image"
return 1
}
new_image_id="$(docker_image_id "$base_image")"
[ "$new_image_id" == "$previous_base_image" ] && {
err "Image was not updated correctly (same id)."
return 1
}
printf "%s\0" "$previous_base_image" "$new_image_id" > "$cache_file"
info "Wrote cache file $cache_file"
}
export -f docker_update
image_exposed_ports_0() {
local image="$1"
docker inspect --format='{{range $p, $conf := .Config.ExposedPorts}}{{$p}}{{"\x00"}}{{end}}' "$image"

Loading…
Cancel
Save