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

DEV - Simplify Docker images #841

Merged
merged 20 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
data
examples/docker/data

# ignore test files
conda-store-server/tests
conda-store/tests
trallard marked this conversation as resolved.
Show resolved Hide resolved
33 changes: 24 additions & 9 deletions conda-store-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
FROM condaforge/mambaforge:23.3.1-1 as base
FROM condaforge/mambaforge:24.3.0-0 as base

LABEL org.opencontainers.image.authors="conda-store development team"

ENV PATH=/opt/conda/condabin:/opt/conda/envs/conda-store-server/bin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PATH}
ENV TZ=Etc/UTC

ARG python_version=3.10
peytondmurray marked this conversation as resolved.
Show resolved Hide resolved
ARG conda_env_name="conda-store-server"

RUN apt-get update && \

Check warning on line 10 in conda-store-server/Dockerfile

View workflow job for this annotation

GitHub Actions / Build docker images (conda-store-server)

Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`
# https://docs.anaconda.org/anaconda/install/linux/#installing-on-linux
apt-get install -yq --no-install-recommends \
libgl1-mesa-glx \
Expand Down Expand Up @@ -39,28 +41,41 @@

USER 1000:1000

COPY environment.yaml /opt/conda-store-server/environment.yaml
RUN mamba create --name ${conda_env_name} \
python=${python_version} conda \
--channel conda-forge -y && \
conda clean --force-pkgs-dirs --all -y

RUN mamba env create -f /opt/conda-store-server/environment.yaml && \
conda clean --force-pkgs-dirs
# ensure we are using the conda environment
ENV PATH=/opt/conda/condabin:/opt/conda/envs/conda-store-server/bin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PATH}
trallard marked this conversation as resolved.
Show resolved Hide resolved

COPY ./ /opt/conda-store-server/

USER 0:0
RUN chown -R 1000:1000 /opt/conda-store-server/
USER 1000:1000

# ---------------------------------------------------------------------------------
# for production-ready images we install a specific version of conda-store-server
FROM base as prod

ARG RELEASE_VERSION
RUN cd /opt/conda-store-server && \
/opt/conda/envs/conda-store-server/bin/pip install conda-store-server==${RELEASE_VERSION} && \

WORKDIR /opt/conda-store-server
RUN which python && \
python -m pip install conda-store-server==${RELEASE_VERSION} --no-cache-dir && \
rm -rf /opt/conda-store-server/tests

WORKDIR /var/lib/conda-store
# ---------------------------------------------------------------------------------

# ---------------------------------------------------------------------------------
# for development images we install conda-store-server in editable mode
FROM base as dev

RUN cd /opt/conda-store-server && \
/opt/conda/envs/conda-store-server/bin/pip install -e .
WORKDIR /opt/conda-store-server
RUN which python && \
python -m pip install -e . --no-cache-dir

WORKDIR /var/lib/conda-store
# ---------------------------------------------------------------------------------
9 changes: 0 additions & 9 deletions conda-store-server/environment.yaml

This file was deleted.

26 changes: 20 additions & 6 deletions conda-store/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM condaforge/mambaforge:23.3.1-1 as base
FROM condaforge/mambaforge:24.3.0-0 as base

LABEL org.opencontainers.image.authors="conda-store development team"

RUN apt-get update && \

Check warning on line 5 in conda-store/Dockerfile

View workflow job for this annotation

GitHub Actions / Build docker images (conda-store)

Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`
apt-get install -yq --no-install-recommends curl && \
apt-get clean && \
rm -rf /var/cache/apt/* &&\
Expand All @@ -16,22 +16,36 @@
COPY environment.yaml /opt/conda-store/environment.yaml

RUN mamba env create -f /opt/conda-store/environment.yaml && \
mamba clean --all -y && \
conda clean --force-pkgs-dirs
mamba clean --all -y && \
conda clean --force-pkgs-dirs

# ensure we are using the conda environment
ENV PATH=/opt/conda/condabin:/opt/conda/envs/conda-store/bin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PATH}

COPY ./ /opt/conda-store/

# ---------------------------------------------------------------------------------
# for production-ready images we install a specific version of conda-store
FROM base as prod

ARG RELEASE_VERSION
RUN cd /opt/conda-store && \
pip install conda-store==${RELEASE_VERSION}

WORKDIR /opt/conda-store
RUN which python && \
python -m pip install conda-store==${RELEASE_VERSION} --no-cache-dir

USER conda-store
WORKDIR /opt/jupyterhub
# ---------------------------------------------------------------------------------

# ---------------------------------------------------------------------------------
# for development images we install conda-store-server in editable mode
FROM base as dev

RUN --mount=type=cache,target=/root/.cache/pip cd /opt/conda-store && \

Check warning on line 45 in conda-store/Dockerfile

View workflow job for this annotation

GitHub Actions / Build docker images (conda-store)

Use WORKDIR to switch to a directory
pip install -e . --no-cache
which python && \
python -m pip install -e . --no-cache-dir

USER conda-store
WORKDIR /opt/jupyterhub
# ---------------------------------------------------------------------------------
3 changes: 3 additions & 0 deletions conda-store/environment.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# This environment file should only be used to build conda-store Docker images
# for development purposes only - these images are built through GitHub actions
name: conda-store
channels:
- conda-forge
dependencies:
- python=3.10
peytondmurray marked this conversation as resolved.
Show resolved Hide resolved
- nb_conda_kernels
- nodejs=18
- yarn
Expand Down
Loading