Skip to content

Commit

Permalink
Docker update (#301)
Browse files Browse the repository at this point in the history
* update docker builds

* limit platforms

* cleanups
  • Loading branch information
hobu committed Apr 27, 2023
1 parent 681f4aa commit 8bd179c
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 84 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
echo ::set-output name=BUILD_DATE::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
echo ::set-output name=VERSION::${VERSION}
- name: Build image
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
push: ${{ env.PUSH_PACKAGES == 'true' }}
builder: ${{ steps.buildx.outputs.name }}
Expand Down
70 changes: 58 additions & 12 deletions scripts/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,73 @@
FROM condaforge/mambaforge:latest as build
MAINTAINER Connor Manning <connor@hobu.co>
ARG BASE_IMAGE="ubuntu:22.04"
FROM --platform=$TARGETPLATFORM condaforge/mambaforge:latest as build

ARG branch=master
RUN echo Branch: $branch
ADD https://api.github.com/repos/connormanning/entwine/commits?sha=$branch \
/tmp/bust-cache
ARG TARGETPLATFORM
ARG TARGETARCH
ARG TARGETVARIANT
ARG BRANCH=master
RUN printf "I'm building for TARGETPLATFORM=${TARGETPLATFORM}" \
&& printf ", TARGETARCH=${TARGETARCH}" \
&& printf ", TARGETVARIANT=${TARGETVARIANT} \n" \
&& printf "With uname -s : " && uname -s \
&& printf "and uname -m : " && uname -m \
&& printf "and branch: ${BRANCH}"


SHELL ["conda", "run", "-n", "base", "/bin/bash", "-c"]
#RUN echo Branch: $branch
#ADD https://api.github.com/repos/connormanning/entwine/commits?sha=$branch \
# /tmp/bust-cache

RUN mamba install -c conda-forge ninja cmake compilers
RUN mamba install -c conda-forge entwine --only-deps
RUN mamba install -c conda-forge conda-pack -y
RUN mamba create -n build -y -c conda-forge ninja cmake compilers
RUN mamba create -n entwine -y

SHELL ["conda", "run", "-n", "build", "/bin/bash", "-c"]

RUN mamba install -y -c conda-forge entwine --only-deps

RUN git clone https://github.com/connormanning/entwine.git /var/entwine && \
cd /var/entwine && \
git checkout $branch && \
git checkout $BRANCH && \
mkdir build && \
cd build && \
cmake -G Ninja \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \
-DCMAKE_BUILD_TYPE=Release .. && \
ninja && \
ninja install

ENTRYPOINT ["entwine"]
SHELL ["conda", "run", "-n", "entwine", "/bin/bash", "-c"]

ENV CONDA_ENV_NAME "entwine"
ENV CONDAENV "/opt/conda/envs/${CONDA_ENV_NAME}"

RUN mamba install -c conda-forge entwine --only-deps
RUN cp /opt/conda/envs/build/bin/entwine $CONDAENV/bin/entwine
RUN cp /opt/conda/envs/build/lib/libentwine.so* $CONDAENV/lib

SHELL ["conda", "run", "-n", "base", "/bin/bash", "-c"]

RUN conda-pack -n ${CONDA_ENV_NAME} --dest-prefix=/var/task -o /tmp/env.tar && \
mkdir /venv && cd /venv && tar xf /tmp/env.tar && \
rm /tmp/env.tar

FROM --platform=$TARGETPLATFORM ${BASE_IMAGE:?} as al2

ARG BASE_IMAGE
ARG TARGETPLATFORM
ARG TARGETARCH

ENV CONDAENV "/var/task"
ENV CONDA_PREFIX "/var/task"
ENV TARGETPLATFORM "${TARGETPLATFORM}"
COPY --from=build /venv ${CONDAENV}


ENV PROJ_LIB ${CONDAENV}/share/proj
ENV PROJ_NETWORK=TRUE
ENV PATH $PATH:${CONDAENV}/bin
ENV LD_LIBRARY_PATH=${CONDAENV}/lib

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

ENTRYPOINT ["entwine"]
42 changes: 0 additions & 42 deletions scripts/docker/Dockerfile.dependencies

This file was deleted.

19 changes: 0 additions & 19 deletions scripts/docker/conda/Dockerfile

This file was deleted.

10 changes: 0 additions & 10 deletions scripts/docker/conda/entrypoint.sh

This file was deleted.

0 comments on commit 8bd179c

Please sign in to comment.