Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config for Accelerator Physics conda env #32

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

mrakitin
Copy link
Collaborator

@mrakitin
Copy link
Collaborator Author

Here is an example of the output files after rendering:

$ python render.py -c configs/apv2-test.yml -f Dockerfile.j2 -f runner.sh.j2
Dockerfile
runner-apv2-test.sh
$ cat Dockerfile
FROM quay.io/condaforge/linux-anvil-comp7:latest as build

ENV env_name="apv2-test"
ENV python_version=""
ENV pkg_name=""
ENV extra_packages="mamba"
ENV channels="-c conda-forge"
ENV conda_env_file="apv2-test.yml"
ENV conda_binary="mamba"
ENV HOME="/home/conda"

# RUN echo "always_yes: true\n\
# envs_dirs:\n\
#   - ~/conda_envs\n\
#   - /opt/conda_envs" >> /home/conda/.condarc

RUN yum install mesa-libGL -y && yum clean all

COPY export.sh ${HOME}/export.sh

COPY envs/${conda_env_file} ${HOME}/${conda_env_file}

RUN source /opt/conda/etc/profile.d/conda.sh && \
    conda install -y ${channels} conda mamba && \
    mamba env create -p /opt/conda_envs/${env_name} --file=${HOME}/${conda_env_file} conda-pack
$ cat runner-apv2-test.sh
#!/bin/bash

set -vxeuo pipefail

export docker_image="quay.io/condaforge/linux-anvil-comp7:latest"
export env_name="apv2-test"
export conda_env_file="apv2-test.yml"
export conda_binary="mamba"
export python_version=""
export pkg_name=""
export pkg_version=""
export extra_packages="mamba"
export channels="-c conda-forge"
export extra_cmd_before_install="yum install mesa-libGL -y"
export extra_cmd_after_install=""
export docker_upload="['ghcr', 'dockerhub']"
export zenodo_upload="no"
export script_name="runner-apv2-test.sh"

if [ -f "${env_name}.tar.gz" ]; then
    echo -e "File ${env_name}.tar.gz exists. Move it or remove it before proceeding."
    exit 1
fi

export build_dir="/build"
repo_dir="/repo"
artifacts_dir="${PWD}/artifacts"
mkdir -m 0777 -v -p ${artifacts_dir}

timestamp=$(date +%Y%m%d%H%M%S)

docker image build . -t ${env_name}:latest \
                     -t ${env_name}:${timestamp}

daemon_mode="${GITHUB_ACTIONS:-false}"
if [ "${daemon_mode}" == "true" ]; then
    interactive="-d"
else
    interactive="-it"
fi
docker_run_cmd="docker run ${interactive} --rm --name ${env_name} \
                    -v ${artifacts_dir}:${build_dir}:rw,z,delegated \
                    -v ${PWD}:${repo_dir} \
                    -e env_name -e channels -e build_dir \
                    ${env_name}:${timestamp} bash ${repo_dir}/export.sh"
echo -e "docker run command:\n\n${docker_run_cmd}\n"

if [ "${daemon_mode}" == "true" ]; then
    container_id=$(${docker_run_cmd})
    docker logs --follow $container_id
else
    ${docker_run_cmd}
fi

# echo $GITHUB_TOKEN | docker login ghcr.io --username $GITHUB_USERNAME --password-stdin
# docker tag ${env_name}:${timestamp} ghcr.io/$GITHUB_USERNAME/${env_name}:${timestamp}
# docker tag ${env_name}:${timestamp} ghcr.io/$GITHUB_USERNAME/${env_name}:latest
# docker image push ghcr.io/$GITHUB_USERNAME/${env_name}:${timestamp}
# docker image push ghcr.io/$GITHUB_USERNAME/${env_name}:latest


# echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin
# docker tag ${env_name}:${timestamp} $DOCKER_REPO:${timestamp}
# docker tag ${env_name}:${timestamp} $DOCKER_REPO:latest
# docker push $DOCKER_REPO:${timestamp}
# docker push $DOCKER_REPO:latest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant