-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: clean up the build and add comments
- Loading branch information
Showing
1 changed file
with
40 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,17 +8,20 @@ ADD https://loripsum.net/api /opt/docker/etc/gibberish-to-bust-docker-image-cach | |
|
||
COPY conda-lock.yml /tmp/conda-lock.yml | ||
|
||
RUN groupadd -g 32766 lucky && \ | ||
echo "**** install base env ****" && \ | ||
micromamba create --yes --quiet --name cf-feedstock-ops --file /tmp/conda-lock.yml && \ | ||
echo "**** cleanup ****" && \ | ||
micromamba clean --all --force-pkgs-dirs --yes && \ | ||
find "${MAMBA_ROOT_PREFIX}" -follow -type f \( -iname '*.a' -o -iname '*.pyc' -o -iname '*.js.map' \) -delete && \ | ||
echo "**** finalize ****" && \ | ||
chown -R root /opt/conda && \ | ||
chgrp -R lucky /opt/conda && chmod -R g=u /opt/conda && \ | ||
mkdir -p "${MAMBA_ROOT_PREFIX}/locks" && \ | ||
RUN <<EOF | ||
groupadd -g 32766 lucky | ||
echo "**** install base env ****" | ||
micromamba create --yes --quiet --name cf-feedstock-ops --file /tmp/conda-lock.yml | ||
echo "**** cleanup ****" | ||
micromamba clean --all --force-pkgs-dirs --yes | ||
find "${MAMBA_ROOT_PREFIX}" -follow -type f \( -iname '*.a' -o -iname '*.pyc' -o -iname '*.js.map' \) -delete | ||
echo "**** finalize ****" | ||
chown -R root /opt/conda | ||
chgrp -R lucky /opt/conda | ||
chmod -R g=u /opt/conda | ||
mkdir -p "${MAMBA_ROOT_PREFIX}/locks" | ||
chmod 777 "${MAMBA_ROOT_PREFIX}/locks" | ||
EOF | ||
|
||
FROM frolvlad/alpine-glibc:alpine-3.16_glibc-2.34 | ||
LABEL maintainer="conda-forge <[email protected]>" | ||
|
@@ -37,44 +40,52 @@ COPY --from=build-env /usr/bin/micromamba /usr/bin/micromamba | |
# use bash for a while to make conda manipulations easier | ||
SHELL ["/bin/bash", "-l", "-c"] | ||
|
||
# deal with entrypoint and tini | ||
COPY entrypoint_wda /opt/docker/bin/entrypoint | ||
RUN chmod +x /opt/docker/bin/entrypoint && \ | ||
ln -s /opt/conda/envs/$CF_FEEDSTOCK_OPS_ENV/bin/tini /opt/docker/bin/tini | ||
|
||
# not needed right now but keeping just in case | ||
# now install the main code | ||
# COPY . $CF_FEEDSTOCK_OPS_DIR | ||
# FIXME: if we add this back, we will need to add an eval of the | ||
# micromamba shell hook | ||
# RUN micromamba activate $CF_FEEDSTOCK_OPS_ENV && \ | ||
# cd $CF_FEEDSTOCK_OPS_DIR && \ | ||
# pip install --no-deps --no-build-isolation -e . && \ | ||
# cd - | ||
|
||
# now make the conda user for running tasks and set the user | ||
RUN addgroup -g 32766 lucky && \ | ||
# deal with entrypoint, tini, users+groups creation | ||
COPY entrypoint_wda /opt/docker/bin/entrypoint | ||
RUN <<EOF | ||
chmod +x /opt/docker/bin/entrypoint | ||
ln -s /opt/conda/envs/$CF_FEEDSTOCK_OPS_ENV/bin/tini /opt/docker/bin/tini | ||
addgroup -g 32766 lucky | ||
adduser --disabled-password --shell /bin/bash conda | ||
EOF | ||
|
||
# finalize the conda user | ||
ENV HOME=/home/conda \ | ||
USER=conda \ | ||
LOGNAME=conda \ | ||
MAIL=/var/spool/mail/conda \ | ||
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/conda/bin | ||
RUN chown conda:conda $HOME && \ | ||
# cp -R /etc/skel $HOME && \ | ||
# chown -R conda:conda $HOME/skel && \ | ||
# (ls -A1 $HOME/skel | xargs -I {} mv -n $HOME/skel/{} $HOME) && \ | ||
# rm -Rf $HOME/skel && \ | ||
RUN <<EOF | ||
chown conda:conda $HOME | ||
# cp -R /etc/skel $HOME | ||
# chown -R conda:conda $HOME/skel | ||
# (ls -A1 $HOME/skel | xargs -I {} mv -n $HOME/skel/{} $HOME) | ||
# rm -Rf $HOME/skel | ||
cd $HOME | ||
EOF | ||
USER conda | ||
|
||
# deal with git config for user and mounted directory | ||
RUN micromamba shell init -s bash -r /opt/conda && \ | ||
source $HOME/.bashrc && \ | ||
micromamba activate $CF_FEEDSTOCK_OPS_ENV && \ | ||
git config --global --add safe.directory /cf_feedstock_ops_dir && \ | ||
git config --global init.defaultBranch main && \ | ||
git config --global user.email "[email protected]" && \ | ||
git config --global user.name "conda conda" && \ | ||
RUN <<EOF | ||
micromamba shell init -s bash -r /opt/conda | ||
source $HOME/.bashrc | ||
micromamba activate $CF_FEEDSTOCK_OPS_ENV | ||
git config --global --add safe.directory /cf_feedstock_ops_dir | ||
git config --global init.defaultBranch main | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "conda conda" | ||
micromamba deactivate | ||
EOF | ||
|
||
# put the shell back | ||
SHELL ["/bin/sh", "-c"] | ||
|