-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathDockerfile.2stage
161 lines (122 loc) · 5.05 KB
/
Dockerfile.2stage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# Copyright 2018-2024 (c) Cognizant Digital Business, Evolutionary AI. All rights reserved. Issued under the Apache 2.0 License.
#
# First stage: Build the Go-runner executable
# Use Ubuntu 20.04 as the base image
FROM ubuntu:20.04 as builder
# Set environment variable to avoid prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive
ARG GIT_COMMIT
ARG GIT_BRANCH
ENV GIT_COMMIT=${GIT_COMMIT}
ENV GIT_BRANCH=${GIT_BRANCH}
ENV GO_VERSION=1.23.3
# Install dependencies
RUN apt-get update && apt-get install -y --no-install-recommends --no-install-suggests \
wget curl git \
build-essential \
ca-certificates \
&& update-ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install Go 1.21
RUN wget https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz \
&& tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz \
&& rm go${GO_VERSION}.linux-amd64.tar.gz
# Set up Go environment variables
ENV PATH="/usr/local/go/bin:${PATH}"
ENV GOPATH="/go"
ENV PATH="${GOPATH}/bin:${PATH}"
LABEL [email protected]
ENV COMPONENT go_runner
ENV LANG C.UTF-8
ENV APP_HOME /home/leaf
RUN adduser --disabled-password --gecos '' -u 1001 leaf
COPY --chown=leaf:leaf . ${APP_HOME}
RUN chmod +x ${APP_HOME}/go-runner-setup.sh && \
${APP_HOME}/go-runner-setup.sh
USER leaf
WORKDIR ${APP_HOME}
FROM nvidia/cuda:11.0.3-base-ubuntu20.04 as deploy
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \
apt-get install -y locales && \
apt-get install -y language-pack-en && \
update-locale "en_US.UTF-8" && \
apt-get install -y --no-install-recommends ca-certificates apt-transport-https apt-utils && \
apt-get install -y --no-install-recommends wget curl groff less lshw jq htop vim pkg-config unzip && \
apt-get install -y --no-install-recommends libopenblas-base && \
apt-get -y upgrade && \
apt-get clean
# Install AWS CLI version 2
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \
&& unzip awscliv2.zip \
&& ./aws/install \
&& rm -rf awscliv2.zip aws
# Verify the installation
RUN aws --version
RUN echo "/usr/local/nvidia/lib" >> /etc/ld.so.conf.d/nvidia.conf && \
echo "/usr/local/nvidia/lib64" >> /etc/ld.so.conf.d/nvidia.conf
ENV PATH /usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH}
ENV LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64:/usr/local/cuda/lib64
# nvidia-container-runtime
ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
ENV NVIDIA_REQUIRE_CUDA "cuda>=11.2"
RUN apt-get -y update && apt-get install -y --no-install-recommends \
pkg-config \
software-properties-common \
unzip && \
apt-get -y update
# Pick up some TF dependencies
RUN apt-get install -y --no-install-recommends \
build-essential \
libhdf5-serial-dev \
libpng-dev \
libzmq3-dev && \
apt-get clean
RUN apt-get -y update && apt-get install -y make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev llvm libncurses5-dev \
libncursesw5-dev xz-utils libffi-dev liblzma-dev python-openssl
WORKDIR /runner
ENV HOME /runner
ENV PATH $HOME/.pyenv/bin:$PATH
RUN apt-get -y update && apt-get install -y --no-install-recommends git
RUN curl https://pyenv.run | /bin/bash && \
# git clone https://github.com/pyenv/pyenv-update.git $(pyenv root)/plugins/pyenv-update && \
pyenv update && \
echo "eval \"\$(pyenv init --path)\"" >> $HOME/.bashrc && \
echo "eval \"\$(pyenv init -)\"" >> $HOME/.bashrc && \
echo "eval \"\$(pyenv virtualenv-init -)\"" >> $HOME/.bashrc && \
eval "$(pyenv init --path)" && \
eval "$(pyenv init -)" && \
eval "$(pyenv virtualenv-init -)" && \
pyenv install --list | grep " 3\.[56789]" && \
pyenv install 3.10.11 && \
pyenv install 3.12.8 && \
pyenv global 3.10.11
RUN \
eval "$(pyenv init --path)" && \
eval "$(pyenv init -)" && \
eval "$(pyenv virtualenv-init -)" && \
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && \
python3 get-pip.py pip==23.0.1 setuptools==67.4.0 wheel==0.38.4
RUN \
eval "$(pyenv init --path)" && \
eval "$(pyenv init -)" && \
eval "$(pyenv virtualenv-init -)" && \
python3 -m pip install virtualenv && \
python3 -m pip install opencv-python-headless && \
apt-get clean
RUN mkdir -p /runner/certs/aws-sqs
RUN mkdir -p /runner/certs/message
# Enable the ability to debug in-situ for python tasks
# RUN echo 0 | tee /proc/sys/kernel/yama/ptrace_scope
# Add support for richer terminals to aid debugging etc
RUN mkdir -p /lib/terminfo/x && \
mkdir -p /usr/local/share/terminfo/x
COPY cmd/runner/add-ons/termite.terminfo /usr/local/share/terminfo/x/xterm-termite
COPY cmd/runner/add-ons/termite.terminfo /lib/terminfo/x/xterm-termite
ENV NVIDIA_REQUIRE_CUDA=cuda>=11.2
ENV COMPONENT_NAME=runner-linux-amd64-cpu
COPY --chown=leaf:leaf --from=builder /home/leaf/cmd/runner/run.sh /runner/run.sh
COPY --chown=leaf:leaf --from=builder /home/leaf/cmd/runner/bin/${COMPONENT_NAME} /runner/${COMPONENT_NAME}
CMD /bin/bash -C ./run.sh