Skip to content

Commit

Permalink
Merge pull request #36 from simonsobs/onlybase
Browse files Browse the repository at this point in the history
Fix several small issues and add dockerfile example.
  • Loading branch information
tskisner authored May 6, 2024
2 parents 567e3e3 + e9132dd commit 0c783d0
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 3 deletions.
43 changes: 43 additions & 0 deletions Dockerfile_jupyter
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM quay.io/jupyter/minimal-notebook:latest as builder

MAINTAINER Theodore Kisner <[email protected]>

# Use bash

SHELL ["/bin/bash", "-c"]

# Copy files into container

COPY soconda.sh ./soconda.sh

RUN mkdir -p config
COPY config ./config/

RUN mkdir -p deploy
COPY deploy ./deploy/

RUN mkdir -p pkgs
COPY pkgs ./pkgs/

RUN mkdir -p templates
COPY templates ./templates/

RUN mkdir -p tools
COPY tools ./tools/

# Install packages to the base environment

RUN ./deploy/install_docker_jupyter.sh

# ======================================

FROM quay.io/jupyter/minimal-notebook:latest

# Copy our installed software binaries and libraries

COPY --from=builder /opt/conda /opt/conda/

# Imports to create config files

RUN python3 -c "import astropy"
RUN python3 -c "import matplotlib.font_manager as fm; f = fm.FontManager"
35 changes: 35 additions & 0 deletions deploy/install_docker_jupyter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# This assumes that a conda base environment already exists
# in /opt/conda, and that we want to install soconda directly
# to the base environment.

# Location for conda base
base_dir=/opt/conda

# Location of soconda tree. This is assumed to be already
# checked out to the desired branch / tag. This is useful for
# testing if the source tree is bind-mounted somewhere else.
git_dir="."

# Temp package dir
pkg_temp=${HOME}/temp_pkgs
mkdir -p ${pkg_temp}
export CONDA_PKGS_DIRS=${pkg_temp}

#===========================================

# Base environment is already activated
conda update -n base --yes --all conda
conda install -n base --yes --all conda-build conda-verify

# Build things from the default home directory

eval "${git_dir}/soconda.sh" \
-v "$(date +%Y%m%d)" \
-c "site" \
-b "/opt/conda" \
-e "base"

# Remove pkg cache
rm -rf ${pkg_temp}
4 changes: 2 additions & 2 deletions pkgs/libactpol_deps/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ popd
pushd slim_v2_7_1-moby2-1
CFLAGS="-O3 -g -fPIC" \
CXXFLAGS="-O3 -g -fPIC" \
./configure --prefix="${PREFIX}" --with-zzip
make
./configure --prefix="${PREFIX}" --with-zzip && \
make && \
make install
rm -f "${PREFIX}/lib/libactpol_deps*.la"
popd
12 changes: 12 additions & 0 deletions pkgs/libactpol_deps/gcc_hardcode.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff -urN libactpol_deps_orig/sofa_20180130/Makefile libactpol_deps_new/sofa_20180130/Makefile
--- libactpol_deps_orig/sofa_20180130/Makefile 2020-06-22 15:49:10.000000000 -0700
+++ libactpol_deps_new/sofa_20180130/Makefile 2024-04-26 16:56:59.751864213 -0700
@@ -23,7 +23,7 @@
default: $(LIBNAME)

$(LIBNAME): $(OBJECTS)
- gcc -shared -Wl,-soname,[email protected] \
+ $(CC) -shared -Wl,-soname,[email protected] \
-o $@ $(OBJECTS)

clean:
3 changes: 3 additions & 0 deletions pkgs/libactpol_deps/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ package:
source:
url: https://github.com/ACTCollaboration/libactpol_deps/archive/{{ version }}.tar.gz
sha256: {{ sha256 }}
patches:
- gcc_hardcode.patch

build:
number: {{ build }}
Expand All @@ -18,6 +20,7 @@ build:
requirements:
build:
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- {{ compiler('fortran') }}
- llvm-openmp # [osx]
- automake
Expand Down
14 changes: 13 additions & 1 deletion soconda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,14 @@ if [ -z "${envname}" ]; then
envname="soconda"
fi
# The full environment name, including the root and version.
fullenv="${envname}_${version}"
if [ "${envname}" = "base" ]; then
# We are installing directly to the base conda env. This is normally
# a bad idea, but sometimes makes sense (e.g. inside a docker
# container).
fullenv="base"
else
fullenv="${envname}_${version}"
fi
# Determine whether the new environment is a name or a full path.
env_noslash=$(echo "${fullenv}" | sed -e 's/\///g')
if [ "${env_noslash}" != "${fullenv}" ]; then
Expand Down Expand Up @@ -220,6 +227,8 @@ if [ -z "${env_check}" ]; then
else
echo "Activating environment \"${fullenv}\""
conda_exec activate "${fullenv}"
# Ensure that the build folder is added to the channel list
conda config --env --add channels "file://${CONDA_PREFIX}/conda-bld"
fi
conda_exec env list

Expand Down Expand Up @@ -370,3 +379,6 @@ fi
if [ -n "${install_jupyter_setup}" ]; then
source "${scriptdir}/tools/install_jupyter_setup.sh"
fi

# Clean up
conda clean --all --yes

0 comments on commit 0c783d0

Please sign in to comment.