diff --git a/podman-privatebin/.gitlab-ci.yml b/podman-privatebin/.gitlab-ci.yml index f75a92d..7363bf4 100644 --- a/podman-privatebin/.gitlab-ci.yml +++ b/podman-privatebin/.gitlab-ci.yml @@ -10,6 +10,7 @@ privatebin: stage: test script: - cd podman-privatebin + - ./ci_build_images.sh - GARBAYE_PRIVATEBIN_ENV_LISTENPORT=18084 ./05_freshinstall.sh - ./20_enable.sh - ./30_start.sh && sleep 10 diff --git a/podman-privatebin/10_install.sh b/podman-privatebin/10_install.sh index 9bff86f..efca28c 100755 --- a/podman-privatebin/10_install.sh +++ b/podman-privatebin/10_install.sh @@ -12,10 +12,7 @@ if ! podman volume exists ${srvdata_volume} ; then exit 1 fi -git clone -b ${version} --depth=1 https://github.com/PrivateBin/docker-nginx-fpm-alpine && -sed -i "s#mv cfg lib tpl vendor /srv#mv cfg lib tpl vendor /srv \&\& sed -i \\'/Content-Security-Policy\\\|X-XSS-Protection\\\|X-Frame-Options\\\|X-Content-Type-Options/d\\' /srv/lib/Controller.php#" docker-nginx-fpm-alpine/Dockerfile -podman build -t privatebin-nginx-fpm-alpine docker-nginx-fpm-alpine && -rm -rf docker-nginx-fpm-alpine && +podman pull "${privatebin_image}":"${privatebin_version}" && podman volume create ${run_volume} && podman volume create ${tmp_volume} && podman volume create ${varlibnginxtmp_volume} && @@ -27,7 +24,7 @@ podman run -d --read-only --restart=always --name ${container_name} \ -v ${tmp_volume}:/tmp:Z \ -v ${srvdata_volume}:/srv/data:Z \ -v ${varlibnginxtmp_volume}:/var/lib/nginx/tmp:Z \ - privatebin-nginx-fpm-alpine && + "${privatebin_image}":"${privatebin_version}" && ( podman logs -f ${container_name} 2>&1 & ) | grep -q 'NOTICE: ready to handle connections' && podman stop ${container_name} && echo Container ${container_name} successfully built and stopped. diff --git a/podman-privatebin/ci_build_images.sh b/podman-privatebin/ci_build_images.sh new file mode 100755 index 0000000..20300c8 --- /dev/null +++ b/podman-privatebin/ci_build_images.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +ABSDIR="$( dirname "$(readlink -f -- "$0")" )" +source ${ABSDIR}/../functions.sh +source ${ABSDIR}/vars.sh + +ensure_pwd_is_scriptdir +ensure_not_root + +if ! podman image exists ${privatebin_image}:${privatebin_version}; then + git clone -b ${privatebin_version} --depth=1 https://github.com/PrivateBin/docker-nginx-fpm-alpine && + sed -i "s#mv cfg lib tpl vendor /srv#mv cfg lib tpl vendor /srv \&\& sed -i \\'/Content-Security-Policy\\\|X-XSS-Protection\\\|X-Frame-Options\\\|X-Content-Type-Options/d\\' /srv/lib/Controller.php#" docker-nginx-fpm-alpine/Dockerfile && + podman build -t "${privatebin_image}":"${privatebin_version}" docker-nginx-fpm-alpine && + rm -rf docker-nginx-fpm-alpine +else + echo "Image ${privatebin_image}:${privatebin_version} already built" +fi + +oci_push_to_registry ${privatebin_image}:${privatebin_version} diff --git a/podman-privatebin/vars.sh b/podman-privatebin/vars.sh index 0941144..e454531 100755 --- a/podman-privatebin/vars.sh +++ b/podman-privatebin/vars.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +privatebin_image="git.garbaye.fr/garbaye/privatebin-nginx-fpm-alpine" +privatebin_version='1.4.0-alpine3.16' container_name='my-privatebin' service_name="container-${container_name}.service" listen_if="${GARBAYE_PRIVATEBIN_ENV_LISTENIF:-127.0.0.1}" @@ -9,5 +11,4 @@ varlibnginxtmp_volume='privatebin-var-lib-nginx-tmp' run_volume='privatebin-run' tmp_volume='privatebin-tmp' nonpersistent_volumes="${varlibnginxtmp_volume} ${run_volume} ${tmp_volume}" -upstream_images='localhost/privatebin-nginx-fpm-alpine docker.io/library/alpine' -version='1.4.0-alpine3.16' +upstream_images="${privatebin_image} docker.io/library/alpine'