Skip to content

Commit

Permalink
refactor: clean up the build and add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
beckermr committed Oct 2, 2024
1 parent 1cf94d2 commit 71dab22
Showing 1 changed file with 40 additions and 29 deletions.
69 changes: 40 additions & 29 deletions Dockerfile_wda
Original file line number Diff line number Diff line change
Expand Up @@ -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]>"
Expand All @@ -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"]
Expand Down

0 comments on commit 71dab22

Please sign in to comment.