-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile-rosfree
More file actions
165 lines (147 loc) · 5.67 KB
/
Copy pathDockerfile-rosfree
File metadata and controls
165 lines (147 loc) · 5.67 KB
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
161
162
163
164
165
# This Dockerfile is the base image for Mov.ai - Based on Ubuntu 20.04
FROM ubuntu:22.10 AS base
# Labels
LABEL description="MOV.AI Base Image"
LABEL maintainer="devops@mov.ai"
# Arguments
ARG USER_ID=1000
ARG ROS_VERSION="noetic"
ARG APT_REPOSITORY="https://artifacts.aws.cloud.mov.ai/repository"
### Environment config
ENV MOVAI_HOME="/opt/mov.ai" \
ROS_VERSION="$ROS_VERSION" \
ROS_DISTRO="$ROS_VERSION"
ENV APP_PATH="${MOVAI_HOME}/app" \
APP_LOGS="${MOVAI_HOME}/logs" \
APP_UPDATES="${MOVAI_HOME}/updates" \
USER_ID=${USER_ID}
# Create Default User and copy default settings
RUN adduser --uid ${USER_ID} --home ${MOVAI_HOME} --disabled-password --gecos '' movai
COPY --chown=movai:movai files/bashrc.bash ${MOVAI_HOME}/.bashrc
COPY --chown=movai:movai files/welcome ${MOVAI_HOME}/.welcome
# Copy build scripts
COPY files/user-provision.sh /usr/local/bin/
COPY files/install-packages.sh /usr/local/bin/
COPY --chown=movai:movai files/deploy.sh /usr/local/bin/deploy.sh
# Copy startup files
COPY files/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
COPY files/movai-entrypoint.sh /usr/local/bin/movai-entrypoint.sh
# Install base packages
COPY files/packages.bash /tmp/packages.bash
COPY docker/$ROS_VERSION/packages.apt /tmp/packages.apt
# Install requirements for ppa certificates registration
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections &&\
apt-get update &&\
apt-get install -y curl gnupg lsb-release ca-certificates --no-install-recommends &&\
apt-get upgrade -y &&\
apt-get autoremove -y &&\
apt-get clean &&\
rm -rf /var/lib/apt/lists/* &&\
rm -rf /var/log/*
COPY files/apt/movai-ubuntu-archive-proxy.list /etc/apt/sources.list.d/movai-ubuntu-archive-proxy.list
COPY files/apt/movai-ubuntu-ports-proxy.list /etc/apt/sources.list.d/movai-ubuntu-ports-proxy.list
COPY files/apt/movai-ubuntu-security-proxy.list /etc/apt/sources.list.d/movai-ubuntu-security-proxy.list
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN mv /etc/apt/sources.list /etc/apt/sources.list.bck &&\
touch /etc/apt/sources.list &&\
curl -fsSL $APT_REPOSITORY/movai-applications/gpg | apt-key add - &&\
#if [ "$(uname -m)" != "x86_64" ] ; then\
# Remove irrelevant source lists based on architecture
#rm /etc/apt/sources.list.d/movai-ubuntu-ports-proxy.list &&\
#rm /etc/apt/sources.list.d/movai-ubuntu-archive* &&\
#rm /etc/apt/sources.list.d/movai-ubuntu-security* ;\
#redis-tools is not available for arm architectures
#sed -i '/redis-tools/d' /tmp/packages.apt ;\
#fi &&\
apt-get update &&\
/usr/local/bin/install-packages.sh &&\
apt-get clean &&\
rm -rf /var/lib/apt/lists/* &&\
rm -rf /var/log/*
# Run user provision
COPY files/user.rc /tmp/user.rc
RUN /usr/local/bin/user-provision.sh
SHELL ["/bin/bash", "-c"]
WORKDIR ${APP_PATH}
ENTRYPOINT [ "docker-entrypoint.sh" ]
FROM base AS rosfree-python310-builder
ENV PYTHON_VERSION=3.10.19
USER root
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN apt-get update && \
apt-get install -y --no-install-recommends \
dpkg-dev \
gcc \
gnupg \
libbluetooth-dev \
libbz2-dev \
libc6-dev \
libdb-dev \
libffi-dev \
libgdbm-dev \
liblzma-dev \
libncursesw5-dev \
libreadline-dev \
libsqlite3-dev \
libssl-dev \
make \
tk-dev \
uuid-dev \
wget \
xz-utils \
zlib1g-dev \
; \
wget --no-check-certificate --progress=dot:giga https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz && \
tar xzf Python-${PYTHON_VERSION}.tgz && \
cd Python-${PYTHON_VERSION} && \
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
./configure \
--build="$gnuArch" \
--enable-loadable-sqlite-extensions \
--enable-optimizations \
--enable-option-checking=fatal \
--enable-shared \
--with-lto \
--with-system-expat \
--without-ensurepip \
; \
nproc="$(nproc)"; \
EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \
LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \
LDFLAGS="${LDFLAGS:--Wl},--strip-all"; \
make -j "$nproc" \
"EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \
"LDFLAGS=${LDFLAGS:-}" \
; \
# https://github.com/docker-library/python/issues/784
# prevent accidental usage of a system installed libpython of the same version
rm python; \
make -j "$nproc" \
"EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \
"LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \
python \
; \
make altinstall && \
# Remove __pycache__, .a files, test dirs
rm -rf ../Python-${PYTHON_VERSION}* && \
find /usr/local -depth \
\( \
\( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \
-o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \
\) -exec rm -rf '{}' + \
;
FROM base AS rosfree-python310
# Copy Python 3.10 from builder stage
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
COPY --from=rosfree-python310-builder /usr/local/bin/python3.10 /usr/local/bin/python3.10
COPY --from=rosfree-python310-builder /usr/local/lib/python3.10 /usr/local/lib/python3.10
COPY --from=rosfree-python310-builder /usr/local/lib/pkgconfig /usr/local/lib/pkgconfig
COPY --from=rosfree-python310-builder /usr/local/lib/libpython3.10.so* /usr/local/lib/
RUN ldconfig && \
update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.10 100 && \
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 50 && \
update-alternatives --set python3 /usr/local/bin/python3.10 && \
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10 && \
echo "" >> ${MOVAI_HOME}/.bashrc && \
echo "printf '\nInfo:\n\tTo use python3.8, run: sudo update-alternatives --set python3 /usr/bin/python3.8\n'" >> ${MOVAI_HOME}/.bashrc