Skip to content

Instantly share code, notes, and snippets.

@infotroph
Last active September 15, 2022 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save infotroph/1b666a6ad58f201bb901a5e19a6d8df2 to your computer and use it in GitHub Desktop.
Save infotroph/1b666a6ad58f201bb901a5e19a6d8df2 to your computer and use it in GitHub Desktop.
PEcAn docker stack on M1 Mac (POC version)
* built a local ARM tidyverse image (I did this in a tempdir)
- Dockerfile:
```
FROM rocker/r-ver:4.2.1
ENV S6_VERSION=v2.1.0.2
ENV RSTUDIO_VERSION=daily
ENV DEFAULT_USER=rstudio
ENV PANDOC_VERSION=default
ENV PATH=/usr/lib/rstudio-server/bin:$PATH
# Needed for compilation of arrow
RUN apt-get update \
&& apt-get install -y --no-install-recommends cmake \
&& rm -rf /var/lib/apt/lists/*
# Needed for compilation of duckdb
RUN sed -i -e 's/-fpic/-fPIC/' /usr/local/lib/R/etc/Makeconf
RUN /rocker_scripts/install_rstudio.sh
RUN /rocker_scripts/install_pandoc.sh
RUN /rocker_scripts/install_tidyverse.sh
EXPOSE 8787
CMD ["/init"]
```
- `docker build -t pecan/tidyverse:armtest .`
* edited docker/depends/Dockerfile to start `FROM pecan/tidyverse:armtest`, then built depends image:
```
cd docker/depends \
&& docker build \
--tag pecan/depends:armtest \
--build-arg R_VERSION=armtest \
.
```
* built other images: `cd .. && ./docker.sh -i armtest -r armtest`
* docker.sh failed at ed2 model image (ld can't find -lhdf5_fortran, -lhdf5, -lhdf5_hl)
I left ed2 and maespa unbuilt and finished by building sipnet and API manually
when doing this again I'll instead comment out the ed2 and maespa images before running docker.sh
```
docker build \
--tag pecan/model-sipnet-git:armtest \
--build-arg MODEL_VERSION=git \
--build-arg IMAGE_VERSION=armtest \
models/sipnet
docker build \
--tag pecan/model-sipnet-r136:armtest \
--build-arg MODEL_VERSION=r136 \
--build-arg IMAGE_VERSION=armtest \
models/sipnet
docker build \
--tag pecan/api:armtest \
--build-arg IMAGE_VERSION=armtest \
--build-arg PECAN_VERSION="1.7.2.9000" \
--build-arg PECAN_GIT_BRANCH=dash-ess \
--build-arg PECAN_GIT_CHECKSUM="eed4817b50c9669dae3ebbad010bcf2d8530021f" \
--build-arg PECAN_GIT_DATE="Wed Sep 14 13:29:13 2022 -0700" \
apps/api/
```
* Reset shared R libraries (have to do this any time switching versions, esp. if changing between ARM and AMD64 stacks):
```
docker volume rm pecan_lib
docker run -ti --rm -v pecan_lib:/rlib pecan/base:armtest cp -a /usr/local/lib/R/site-library/. /rlib/
```
If you forget this step, loading any R package with shared objects will give e.g.
```
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/usr/local/lib/R/site-library/Rcpp/libs/Rcpp.so': /usr/local/lib/R/site-library/Rcpp/libs/Rcpp.so: cannot open shared object file: No such file or directory
```
* Let's test!
- commented out ed2 and maespa in docker-compose.yml
- `PECAN_VERSION='armtest' docker-compose up`
- Images that are still running as AMD64: bety, dbsync, postgres, thredds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment