Skip to content
Snippets Groups Projects
Verified Commit 35a0cc3c authored by David Hoese's avatar David Hoese
Browse files

Add initial docker build contents

Copied from Geo Floods project
parent 103fb40a
No related branches found
No related tags found
No related merge requests found
Pipeline #60097 failed
......@@ -94,33 +94,81 @@ unit tests:
reports:
junit: report.xml
# specialization to build an image and push back to registry with :latest and :githash versions
#build_ci_image:
# extends: .docker_based_job
# variables:
# DOCKERFILE: "Dockerfile"
# IMAGE_NAME: ""
# IMAGE_DIR: ""
# stage: build image
build python runtime image:
extends: .docker-base
stage: build images
script:
- image_tag=$(ci/default_image_tag.sh)
- echo "PYRUNTIME_TAG=${image_tag}" >> build.env
- ./ci/build_image.sh docker/python_runtime/python_runtime.Containerfile axitools-python-runtime ${image_tag} 1
artifacts:
reports:
dotenv: build.env
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
- changes:
- docker/python_runtime/*
when: on_success
- if: $BUILD_IMAGES
when: on_success
- when: on_success
build bundler:
extends: .docker-base
stage: build bundler
script:
- image_tag=$(ci/default_image_tag.sh)
- echo "BUNDLER_TAG=${image_tag}" >> build.env
- PYTHON_RUNTIME_IMAGE_TAG="$CI_REGISTRY_IMAGE/axitools-python-runtime:${PYRUNTIME_TAG}"
- echo "$PYTHON_RUNTIME_IMAGE_TAG"
- ./ci/build_image.sh docker/bundle/bundler.Containerfile axitools-bundler ${image_tag} 1 --build-arg PYTHON_RUNTIME_IMAGE=$PYTHON_RUNTIME_IMAGE_TAG --build-context bin=bin --build-context repos_root=${PWD}
artifacts:
reports:
dotenv: build.env
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
- changes:
- docker/bundle/*
when: on_success
- if: $BUILD_BUNDLER
when: on_success
- when: on_success
#build tarball:
# extends: .docker-base
# image: "$CI_REGISTRY_IMAGE/ci-image:1.0.2"
# stage: build tarball
# before_script:
# - docker info
# - docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
# - df
# # setup SSH key to upload to bumi
# - eval $(ssh-agent -s)
# - chmod 400 "$id_rsa_floods_upload"
# - ssh-add "$id_rsa_floods_upload"
# - mkdir -p ~/.ssh
# - chmod 700 ~/.ssh
# - cp "$SSH_KNOWN_HOSTS" ~/.ssh/known_hosts
# - chmod 644 ~/.ssh/known_hosts
# script:
# - image_url="${CI_REGISTRY_IMAGE}/${IMAGE_NAME}"
# - if [ -z "$CI_COMMIT_TAG" ]; then
# docker_tag=rGIT${CI_COMMIT_SHORT_SHA};
# else
# docker_tag=${CI_COMMIT_TAG};
# fi;
# - echo $docker_tag
# - docker pull ${image_url}:latest || true
# - docker build --shm-size 6442450944 --cache-from ${image_url}:latest -f "${DOCKERFILE}" -t "${image_url}:latest" -t "${image_url}:${docker_tag}" ${IMAGE_DIR}
# - docker push ${image_url}:${docker_tag}
# - docker push ${image_url}:latest
#
#build_image:
# extends: .build_image
# variables:
# IMAGE_NAME: "axi-tools"
# IMAGE_DIR: "."
# DOCKERFILE: "docker/build.Dockerfile"
# - unset GIT_LFS_SKIP_SMUDGE
# - git lfs pull --include "vendor/$CODE_TARBALL"
# - podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
# - IMAGE_TAG="$CI_REGISTRY_IMAGE/flood-bundler:${BUNDLER_TAG}"
# # bumi gitlab runner has /data/tmp mounted as /work
# - if [[ ! -d /work ]]; then OUT=${PWD}; else OUT=/work; fi
# - VERSION=$(ci/get_bundle_version.sh)
# - BUNDLE_NAME="cspp-geo-abi-flood-mapping-${VERSION}"
# - podman run --rm -u $(id -u):$(id -g) -v ${PWD}/vendor:/vendor -v ${OUT}:/out -e TMPDIR=/out -w /out ${IMAGE_TAG} /work/bin/bundle.sh "${BUNDLE_NAME}"
# # -O is needed otherwise scp might try to use sftp which won't match security checks on SSH key on bumi
# - scp -O -v "${OUT}/${BUNDLE_NAME}.tar.gz" davidh@bumi.ssec.wisc.edu:/data/dist/floods/
# rules:
# - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
# when: never
# - changes:
# - geo_builder/bundle/*
# when: on_success
## - if: $BUILD_TARBALL
## when: always
# - when: on_success
......@@ -4,7 +4,7 @@ AXI_TOOLS_HOME="$( cd -P "$( dirname "$(readlink -f "${BASH_SOURCE[0]}")" )" &&
export AXI_TOOLS_HOME
# Setup necessary environments
# __SWBUNDLE_ENVIRONMENT_INJECTION__
# __BUNDLE_ENV_INJECTION__
# Set best known defaults for number of OpenMP threads
export OMP_NUM_THREADS=${OMP_NUM_THREADS:-1}
......
#!/usr/bin/env bash
debug() {
>&2 echo -e "DEBUG: $*"
}
error() {
>&2 echo -e "ERROR: $*"
exit 1
}
if [[ $# -ne 1 ]]; then
error "Usage: ./bundle.sh <distribution_name>"
fi
dist_name=$1
OUT_DIR=${TMPDIR:-/tmp}
# bundle directory created in current directory
dist_dir="${OUT_DIR}/${dist_name}"
python_runtime_dir="${dist_dir}/libexec/python_runtime"
mkdir -p "${dist_dir}" || error "Could not create distribution directory: ${dist_dir}"
mkdir -p "${dist_dir}/bin" || error "Could not create distribution directory: ${dist_dir}/bin"
mkdir -p "${dist_dir}/vendor/ccap" || error "Could not create distribution directory: ${dist_dir}/bin"
mkdir -p "${python_runtime_dir}" || error "Could not create python runtime directory: ${python_runtime_dir}"
# Python environment
debug "Packing python runtime and unpacking to distribution..."
micromamba clean -afy || error "Couldn't cleanup conda environment"
conda-pack --n-threads -1 --compress-level 0 --prefix /micromamba/envs/pkg_runtime/ -o "${OUT_DIR}/python_runtime.tar.gz" || error "Couldn't pack python environment"
tar --no-same-owner -xzf "${OUT_DIR}/python_runtime.tar.gz" -C "${python_runtime_dir}" || error "Couldn't unpack python environment into distribution"
debug "Removing temporary python runtime tarball"
rm -v "${OUT_DIR}/python_runtime.tar.gz"
# TODO: Apply risky cleanup operations to save space
# Get ancillary data
/work/bin/download_ancillary.sh || error "No ancillary data found"
cp /work/LICENSE "${dist_dir}/"
cp /work/NEWS.md "${dist_dir}/"
cp /work/README.txt "${dist_dir}/"
cp /work/bin/*.sh "${dist_dir}/bin/" || error "Couldn't copy CSPP scripts to bin directory"
rm "${dist_dir}/bin/bundle.sh"
rm "${dist_dir}/bin/download_ancillary.sh"
for script_fn in "${dist_dir}"/bin/*.sh; do
if [[ ${script_fn} == "${dist_dir}/bin/env.sh" ]]; then
continue
fi
# shellcheck disable=SC2016
sed -i 's|# __BUNDLE_ENV_INJECTION__|source ${AXI_TOOLS_HOME}/bin/env.sh|' "$script_fn"
done
# Bundle it all together
debug "Creating final tarball..."
tarball_out="/out/${dist_name}.tar.gz"
cd "$(dirname "${dist_dir}")" || error "Unable to change to distribution parent directory"
tar -czf "${tarball_out}" "${dist_name}" || error "Unable to create distribution tarball"
debug "Removing temporary bundled directory"
rm -r "${dist_dir}"
debug "SUCCESS: Tarball created: ${tarball_out}"
# AXI Tools
## License
See LICENSE.md for more details.
## Installation
Coming soon...
## Execution
Coming soon...
For more details refer to the official documentation or contact
csppgeo.issues@ssec.wisc.edu.
ARG PYTHON_RUNTIME_IMAGE=python_runtime:latest
FROM $PYTHON_RUNTIME_IMAGE AS python_runtime
RUN micromamba install -p /micromamba/envs/pkg_runtime -y conda-pack
COPY --from=repos_root README.md LICENSE pyproject.toml axi_tools python/
RUN /micromamba/envs/pkg_runtime/bin/python3 -m pip install python/
FROM rockylinux:8-minimal
WORKDIR /work
RUN microdnf install tar gzip && microdnf clean all
COPY --from=python_runtime /micromamba /micromamba
COPY --from=python_runtime /bin/micromamba /bin/micromamba
ENV PATH="/micromamba/envs/pkg_runtime/bin/:$PATH"
COPY --chmod=755 bundle.sh ./bin/
COPY --from=bin --chmod=755 ./*.sh ./bin/
COPY --chmod=644 bundle_README.txt ./README.txt
COPY --from=repos_root LICENSE .
COPY --from=repos_root NEWS.md .
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment