Skip to content

Commit

Permalink
Merge pull request #26 from Anaconda-Platform/multi-arch
Browse files Browse the repository at this point in the history
Multi arch builder images
  • Loading branch information
AlbertDeFusco authored Jan 20, 2022
2 parents 9be409d + ab89576 commit 6d9d5a2
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 38 deletions.
27 changes: 18 additions & 9 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,23 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Builder image (${{ matrix.base }})

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Builder and push image (${{ matrix.base }})
run: |
make ${{ matrix.base }}
docker image ls
- name: Push to Docker Hub (${{ matrix.base }})
run: |
GIT_TAG=`git describe --tags --abbrev=0`
docker login --username ${{ secrets.DOCKER_USERNAME }} --password ${{ secrets.DOCKER_PASSWORD }}
docker tag conda/s2i-anaconda-project-${{ matrix.base }}:latest conda/s2i-anaconda-project-${{ matrix.base }}:$GIT_TAG
docker push conda/s2i-anaconda-project-${{ matrix.base }}:latest
docker push conda/s2i-anaconda-project-${{ matrix.base }}:$GIT_TAG
GIT_TAG=`git describe --tags --abbrev=0`
if [ ${{ matrix.base }} == ubi7 ]; then
PLATFORM=linux/amd64
else
PLATFORM=linux/amd64,linux/arm64
fi
make ${{ matrix.base }} PLATFORM=$PLATFORM TAG=latest,$GIT_TAG
17 changes: 13 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
IMAGE_PREFIX = conda/s2i-anaconda-project
BASE_IMAGES := $(basename $(wildcard *.dockerfile))
PLATFORM ?= local
TAG ?= latest
_comma = ,

ifeq ($(PLATFORM), local)
DOCKER_BUILD=docker build
else
DOCKER_BUILD=docker buildx build --platform $(PLATFORM) --push
endif

all: $(BASE_IMAGES)

.PHONY: $(BASE_IMAGES)
$(BASE_IMAGES):
docker build -t $(IMAGE_PREFIX)-$@ -f $@.dockerfile .
$(DOCKER_BUILD) $(foreach tag, $(subst $(_comma), ,$(TAG)), -t $(IMAGE_PREFIX)-$@:$(tag)) -f $@.dockerfile .

TEST_IMAGES := $(patsubst %,test-%,$(BASE_IMAGES))
test: $(TEST_IMAGES)
Expand All @@ -15,9 +24,9 @@ $(TEST_IMAGES):
docker build -t $(IMAGE_PREFIX)-$(patsubst test-%,%,$@)-candidate -f $(patsubst test-%,%,$@).dockerfile .
IMAGE_NAME=$(IMAGE_PREFIX)-$(patsubst test-%,%,$@)-candidate test/run-default
IMAGE_NAME=$(IMAGE_PREFIX)-$(patsubst test-%,%,$@)-candidate test/run-cmd server
IMAGE_NAME=$(IMAGE_PREFIX)-$(patsubst test-%,%,$@)-candidate test/run-multi-env default py3
IMAGE_NAME=$(IMAGE_PREFIX)-$(patsubst test-%,%,$@)-candidate test/run-multi-env py2 py2
IMAGE_NAME=$(IMAGE_PREFIX)-$(patsubst test-%,%,$@)-candidate test/run-multi-env py3 py3
IMAGE_NAME=$(IMAGE_PREFIX)-$(patsubst test-%,%,$@)-candidate test/run-multi-env default py38
IMAGE_NAME=$(IMAGE_PREFIX)-$(patsubst test-%,%,$@)-candidate test/run-multi-env py38 py38
IMAGE_NAME=$(IMAGE_PREFIX)-$(patsubst test-%,%,$@)-candidate test/run-multi-env py39 py39
IMAGE_NAME=$(IMAGE_PREFIX)-$(patsubst test-%,%,$@)-candidate test/run-env-vars "" "CMD_VAR=cmd_value\nPROJECT_VAR=project_value\n"
IMAGE_NAME=$(IMAGE_PREFIX)-$(patsubst test-%,%,$@)-candidate test/run-env-vars "env" "PROJECT_VAR=project_value"
IMAGE_NAME=$(IMAGE_PREFIX)-$(patsubst test-%,%,$@)-candidate test/run-lambda-py
Expand Down
62 changes: 56 additions & 6 deletions alpine.dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,61 @@
FROM frolvlad/alpine-glibc:alpine-3.12_glibc-2.32
FROM alpine:3.15.0 as alpine-glibc

LABEL maintainer="Vlad Frolov"
LABEL src=https://github.com/frol/docker-alpine-glibc
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8

SHELL ["/bin/ash", "-eo", "pipefail", "-c"]

ENV ALPINE_GLIBC_PACKAGE_VERSION="2.32-r0"

# hadolint ignore=DL3018
RUN UNAME_M="$(uname -m)" && \
if [ "${UNAME_M}" = "x86_64" ]; then \
ARCH="x86_64"; \
GH_ACCT="sgerrand"; \
SUFFIX=""; \
elif [ "${UNAME_M}" = "aarch64" ]; then \
ARCH="arm64"; \
GH_ACCT="ljfranklin"; \
SUFFIX="-${ARCH}"; \
fi && \
ALPINE_GLIBC_BASE_URL="https://github.com/${GH_ACCT}/alpine-pkg-glibc/releases/download" && \
echo $ALPINE_GLIBC_BASE_URL && \
ALPINE_GLIBC_BASE_PACKAGE_FILENAME="glibc-$ALPINE_GLIBC_PACKAGE_VERSION.apk" && \
ALPINE_GLIBC_BIN_PACKAGE_FILENAME="glibc-bin-$ALPINE_GLIBC_PACKAGE_VERSION.apk" && \
ALPINE_GLIBC_I18N_PACKAGE_FILENAME="glibc-i18n-$ALPINE_GLIBC_PACKAGE_VERSION.apk" && \
apk add -q --no-cache --virtual=.build-dependencies wget ca-certificates && \
wget -q \
"$ALPINE_GLIBC_BASE_URL/${ALPINE_GLIBC_PACKAGE_VERSION}${SUFFIX}/$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \
"$ALPINE_GLIBC_BASE_URL/${ALPINE_GLIBC_PACKAGE_VERSION}${SUFFIX}/$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \
"$ALPINE_GLIBC_BASE_URL/${ALPINE_GLIBC_PACKAGE_VERSION}${SUFFIX}/$ALPINE_GLIBC_I18N_PACKAGE_FILENAME" && \
apk --allow-untrusted add -q --no-cache \
"$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \
"$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \
"$ALPINE_GLIBC_I18N_PACKAGE_FILENAME" && \
\
/usr/glibc-compat/bin/localedef --force --inputfile POSIX --charmap UTF-8 "$LANG" || true && \
echo "export LANG=$LANG" > /etc/profile.d/locale.sh && \
\
apk del -q glibc-i18n && \
\
rm "/root/.wget-hsts" && \
apk del -q .build-dependencies && \
rm \
"$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \
"$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \
"$ALPINE_GLIBC_I18N_PACKAGE_FILENAME"


FROM alpine-glibc

LABEL maintainer="Anaconda, Inc."

ENV CONDA_VERSION=4.9.2
ENV ANACONDA_PROJECT_VERSION=0.10.0
ARG CONDA_VERSION=py39_4.10.3
ARG ANACONDA_PROJECT_VERSION=0.10.2

LABEL io.k8s.description="Run Anaconda Project commands" \
io.k8s.display-name="Anaconda Project 0.10.0" \
io.k8s.display-name="Anaconda Project ${ANACONDA_PROJECT_VERSION}" \
io.openshift.expose-services="8086:http" \
io.openshift.tags="builder,anaconda-project,conda" \
io.openshift.s2i.scripts-url=image:///usr/libexec/s2i
Expand All @@ -27,11 +76,12 @@ RUN apk add --no-cache tzdata \
### Install and configure miniconda
COPY ./etc/condarc /opt/conda/.condarc
RUN apk add --no-cache --virtual wget tar bash curl \
&& wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-py37_4.9.2-Linux-x86_64.sh -O miniconda.sh \
&& UNAME_M="$(uname -m)" \
&& wget "https://repo.anaconda.com/miniconda/Miniconda3-${CONDA_VERSION}-Linux-${UNAME_M}.sh" -O miniconda.sh -q \
&& sh miniconda.sh -u -b -p /opt/conda \
&& rm -f miniconda.sh \
&& ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh \
&& conda install anaconda-project=0.10.0 anaconda-client conda-repo-cli conda-token tini --yes \
&& conda install anaconda-project=${ANACONDA_PROJECT_VERSION} anaconda-client conda-repo-cli conda-token conda-forge::tini --yes \
&& conda clean --all --yes \
&& chmod -R 755 /opt/conda

Expand Down
4 changes: 4 additions & 0 deletions test/test-lambda-api/anaconda-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: test-lambda
packages:
- jq

channels:
- defaults
- conda-forge

commands:
default:
unix: jq -ncM '$in | .Key = "output"' --argjson in
5 changes: 5 additions & 0 deletions test/test-lambda-py/app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import logging
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)

def handler(event, context):
event['Key'] = 'output'
logger.debug(event)
return event
14 changes: 7 additions & 7 deletions test/test-multi-env/anaconda-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ name: MultiEnv
description: test multiple env_specs

env_specs:
py3:
py38:
packages:
- python=3.8
py2:
py39:
packages:
- python=2.7
- python=3.9

commands:
py3:
py38:
unix: python -c "import sys,os;print(os.path.basename(sys.prefix))"
env_spec: py3
env_spec: py38
supports_http_options: false
py2:
py39:
unix: python -c "import sys,os;print(os.path.basename(sys.prefix))"
env_spec: py2
env_spec: py39
supports_http_options: false
13 changes: 7 additions & 6 deletions ubi7.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ FROM registry.access.redhat.com/ubi7/s2i-base

LABEL maintainer="Anaconda, Inc."

ENV CONDA_VERSION=4.9.2
ENV ANACONDA_PROJECT_VERSION=0.10.0
ARG CONDA_VERSION=py39_4.10.3
ARG ANACONDA_PROJECT_VERSION=0.10.2

LABEL io.k8s.description="Run Anaconda Project commands" \
io.k8s.display-name="Anaconda Project 0.10.0" \
io.k8s.display-name="Anaconda Project ${ANACONDA_PROJECT_VERSION}" \
io.openshift.expose-services="8086:http" \
io.openshift.tags="builder,anaconda-project,conda"

Expand All @@ -22,12 +22,13 @@ RUN chmod +x /opt/aws/aws-lambda-rie

### Install and configure miniconda
COPY ./etc/condarc /opt/conda/.condarc
RUN yum install -y wget bzip2 \
&& wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-py37_4.9.2-Linux-x86_64.sh -O miniconda.sh \
RUN yum install -y wget bzip2 curl \
&& UNAME_M="$(uname -m)" \
&& wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-${CONDA_VERSION}-Linux-${UNAME_M}.sh -O miniconda.sh \
&& bash miniconda.sh -u -b -p /opt/conda \
&& rm -f miniconda.sh \
&& ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh \
&& conda install anaconda-project=0.10.0 anaconda-client conda-repo-cli conda-token tini --yes \
&& conda install anaconda-project=${ANACONDA_PROJECT_VERSION} anaconda-client conda-repo-cli conda-token tini --yes \
&& conda clean --all --yes \
&& chmod -R 755 /opt/conda

Expand Down
13 changes: 7 additions & 6 deletions ubi8.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ FROM registry.access.redhat.com/ubi8/s2i-base

LABEL maintainer="Anaconda, Inc."

ENV CONDA_VERSION=4.9.2
ENV ANACONDA_PROJECT_VERSION=0.10.0
ARG CONDA_VERSION=py39_4.10.3
ARG ANACONDA_PROJECT_VERSION=0.10.2

LABEL io.k8s.description="Run Anaconda Project commands" \
io.k8s.display-name="Anaconda Project 0.10.0" \
io.k8s.display-name="Anaconda Project ${ANACONDA_PROJECT_VERSION}" \
io.openshift.expose-services="8086:http" \
io.openshift.tags="builder,anaconda-project,conda"

Expand All @@ -22,12 +22,13 @@ RUN chmod +x /opt/aws/aws-lambda-rie

### Install and configure miniconda
COPY ./etc/condarc /opt/conda/.condarc
RUN yum install -y wget bzip2 \
&& wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-py37_4.9.2-Linux-x86_64.sh -O miniconda.sh \
RUN yum install -y wget bzip2 curl \
&& UNAME_M="$(uname -m)" \
&& wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-${CONDA_VERSION}-Linux-${UNAME_M}.sh -O miniconda.sh \
&& bash miniconda.sh -u -b -p /opt/conda \
&& rm -f miniconda.sh \
&& ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh \
&& conda install anaconda-project=0.10.0 anaconda-client conda-repo-cli conda-token tini --yes \
&& conda install anaconda-project=${ANACONDA_PROJECT_VERSION} anaconda-client conda-repo-cli conda-token conda-forge::tini --yes \
&& conda clean --all --yes \
&& chmod -R 755 /opt/conda

Expand Down

0 comments on commit 6d9d5a2

Please sign in to comment.