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

fix: add a docker ignore file for the base container #121

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions base/buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ context:
requirements:
source: ../../base/jobs/docker/1.0/py3/requirements.txt
target: requirements.txt
dockerignore:
source: ../../base/jobs/docker/1.0/py3/.dockerignore
target: .dockerignore

images:
BuildBaseCPUJobsPy3DockerImage:
Expand Down
15 changes: 15 additions & 0 deletions base/jobs/docker/1.0/py3/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
pip-log.txt
pip-delete-this-directory.txt
.tox
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.log
.git
.mypy_cache
.pytest_cache
.hypothesis
.DS_Store
51 changes: 26 additions & 25 deletions base/jobs/docker/1.0/py3/Dockerfile.cpu
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# This is based loosely on :
# https://github.com/aws/amazon-sagemaker-examples/blob/master/advanced_functionality/custom-training-containers/script-mode-container/docker/Dockerfile

FROM public.ecr.aws/lts/ubuntu:22.04

LABEL maintainer="Amazon Braket"
LABEL major_version="1"
# Has Python 3.10
FROM public.ecr.aws/lts/ubuntu:22.04 as common

# prevent stopping by user interaction
ENV DEBIAN_FRONTEND noninteractive
Expand All @@ -16,11 +14,19 @@ ENV PYTHONIOENCODING=UTF-8
ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8

# Switch off pip cache in the env
ENV PIP_NO_CACHE_DIR=1

ARG PYTHON=python3.10
ARG PYTHON_PIP=python3-pip
ARG PIP=pip3
ARG PIP=pip
ARG PYTHON_VERSION=3.10.11

# To be passed to later stages
ENV PYTHON=${PYTHON}
ENV PYTHON_VERSION=${PYTHON_VERSION}
ENV PIP=${PIP}

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
Expand All @@ -32,15 +38,14 @@ RUN apt-get update \
libtemplate-perl \
libssl3 \
openssl \
python3-dev \
python3-pip \
unzip \
wget \
zlib1g-dev \
# Install dependent library for OpenCV
libgtk2.0-dev \
&& rm -rf /var/lib/apt/lists/*

# Install Open MPI
RUN mkdir /tmp/openmpi \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir /tmp/openmpi \
&& cd /tmp/openmpi \
&& curl -fSsL -O https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-4.0.4.tar.gz \
&& tar zxf openmpi-4.0.4.tar.gz \
Expand All @@ -49,15 +54,15 @@ RUN mkdir /tmp/openmpi \
&& make -j $(nproc) all \
&& make install \
&& ldconfig \
&& rm -rf /tmp/openmpi
&& rm -rf /tmp/openmpi \

# Create a wrapper for OpenMPI to allow running as root by default
RUN mv /usr/local/bin/mpirun /usr/local/bin/mpirun.real \
&& mv /usr/local/bin/mpirun /usr/local/bin/mpirun.real \
&& echo '#!/bin/bash' > /usr/local/bin/mpirun \
&& echo 'mpirun.real --allow-run-as-root "$@"' >> /usr/local/bin/mpirun \
&& chmod a+x /usr/local/bin/mpirun
&& chmod a+x /usr/local/bin/mpirun \

RUN echo "hwloc_base_binding_policy = none" >> /usr/local/etc/openmpi-mca-params.conf \
&& echo "hwloc_base_binding_policy = none" >> /usr/local/etc/openmpi-mca-params.conf \
&& echo "rmaps_base_mapping_policy = slot" >> /usr/local/etc/openmpi-mca-params.conf

ENV LD_LIBRARY_PATH=/usr/local/openmpi/lib:/usr/local/lib:$LD_LIBRARY_PATH
Expand Down Expand Up @@ -87,25 +92,21 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean

# Installing Python3
RUN wget https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz \
&& tar -xvf Python-$PYTHON_VERSION.tgz \
&& cd Python-$PYTHON_VERSION \
&& ./configure && make && make install \
&& rm -rf ../Python-$PYTHON_VERSION*
COPY .dockerignore .dockerignore

RUN ln -s $(which ${PYTHON}) /usr/local/bin/python

# Upgrading pip and creating symbolic link for python3
RUN ${PIP} --no-cache-dir install --upgrade pip setuptools
RUN ln -s $(which ${PYTHON}) /usr/local/bin/python \
&& ln -s $(which ${PIP}) /usr/bin/pip
RUN ${PIP} --no-cache-dir install --upgrade \
pip \
requests \
setuptools

WORKDIR /

RUN apt-get update && apt-get -y install cmake protobuf-compiler

# Copy the dependencies file
COPY requirements.txt /
# Installing our custom python libraries
RUN ${PIP} install --no-cache --upgrade \
-r requirements.txt

Expand Down