Use bash by default in the build environment Docker container (#3879)

* Add entrypoint.sh

Signed-off-by: quicksilver <zhifeng.zhang@zilliz.com>

* Add entrypoint.sh

Signed-off-by: quicksilver <zhifeng.zhang@zilliz.com>

* Update docker-compose.yaml

Signed-off-by: quicksilver <zhifeng.zhang@zilliz.com>

* Update milvus build environment dockerfile

Signed-off-by: quicksilver <zhifeng.zhang@zilliz.com>

* Update milvus build environment dockerfile

Signed-off-by: quicksilver <zhifeng.zhang@zilliz.com>

* Update milvus build environment docker entrypoint file

Signed-off-by: quicksilver <zhifeng.zhang@zilliz.com>
pull/3874/head^2
quicksilver 2020-09-26 10:48:20 +08:00 committed by GitHub
parent b03362bbbd
commit 0c06e2a155
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 68 additions and 77 deletions

View File

@ -7,7 +7,7 @@ on:
paths:
- 'ci/**'
- 'core/**'
- 'docker/build_env/cpu/**'
- 'docker/build_env/**'
- '.github/workflows/core.yml'
- docker-compose.yml
- '!**.md'

View File

@ -7,7 +7,7 @@ on:
paths:
- 'ci/**'
- 'core/**'
- 'docker/build_env/cpu/**'
- 'docker/build_env/**'
- '.github/workflows/cpplint.yml'
- docker-compose.yml
- '!**.md'

View File

@ -24,7 +24,7 @@ services:
networks:
- milvus
command: &ubuntu-command
["/milvus/ci/scripts/build.sh -t Release -j2 -i ${MILVUS_INSTALL_PREFIX} --with_fiu --coverage -u &&
["/bin/bash", "-l", "-c", "/milvus/ci/scripts/build.sh -t Release -j2 -i ${MILVUS_INSTALL_PREFIX} --with_fiu --coverage -u &&
/milvus/ci/scripts/run_unittest.sh -i ${MILVUS_INSTALL_PREFIX}"]
centos-core:
@ -43,7 +43,7 @@ services:
networks:
- milvus
command: &centos-command
["/milvus/ci/scripts/build.sh -t Release -j2 -i ${MILVUS_INSTALL_PREFIX} --with_fiu --coverage -u &&
["/bin/bash", "-l", "-c", "/milvus/ci/scripts/build.sh -t Release -j2 -i ${MILVUS_INSTALL_PREFIX} --with_fiu --coverage -u &&
/milvus/ci/scripts/run_unittest.sh -i ${MILVUS_INSTALL_PREFIX}"]
ubuntu-cuda-core:
@ -62,7 +62,7 @@ services:
networks:
- milvus
command: &ubuntu-cuda-command
["/milvus/ci/scripts/build.sh -t Release -j2 -i ${MILVUS_INSTALL_PREFIX} -g"]
["/bin/bash", "-l", "-c", "/milvus/ci/scripts/build.sh -t Release -j2 -i ${MILVUS_INSTALL_PREFIX} -g"]
centos-cuda-core:
image: ${REPO}:${ARCH}-centos-${CENTOS}-cuda-core
@ -80,7 +80,7 @@ services:
networks:
- milvus
command: &centos-cuda-command
["/milvus/ci/scripts/build.sh -t Release -j2 -i ${MILVUS_INSTALL_PREFIX} -g"]
["/bin/bash", "-l", "-c", "/milvus/ci/scripts/build.sh -t Release -j2 -i ${MILVUS_INSTALL_PREFIX} -g"]
cpplint:
image: ${REPO}:${ARCH}-centos-${CENTOS}-core
@ -95,7 +95,7 @@ services:
networks:
- milvus
command:
["/milvus/ci/scripts/build.sh -t Release -j2 -i ${MILVUS_INSTALL_PREFIX} -l --tidy -n"]
["/bin/bash", "-l", "-c", "/milvus/ci/scripts/build.sh -t Release -j2 -i ${MILVUS_INSTALL_PREFIX} -l --tidy -n"]
cpplint-gpu:
image: ${REPO}:${ARCH}-centos-${CENTOS}-cuda-core
@ -110,7 +110,7 @@ services:
networks:
- milvus
command:
["/milvus/ci/scripts/build.sh -t Release -j2 -i ${MILVUS_INSTALL_PREFIX} -l -g --tidy -n"]
["/bin/bash", "-l", "-c", "/milvus/ci/scripts/build.sh -t Release -j2 -i ${MILVUS_INSTALL_PREFIX} -l -g --tidy -n"]
networks:
milvus:

View File

@ -36,8 +36,10 @@ RUN yum install -y ccache && \
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib"
# use login shell to activate environment un the RUN commands
SHELL [ "/bin/bash", "-c", "-l" ]
# Set permissions on /etc/passwd and /home to allow arbitrary users to write
COPY --chown=0:0 docker/build_env/entrypoint.sh /
RUN mkdir -p /home/user && chgrp -R 0 /home && chmod -R g=u /etc/passwd /etc/group /home && chmod +x /entrypoint.sh
# use login shell when running the container
ENTRYPOINT [ "/bin/bash", "-c", "-l" ]
ENV HOME=/home/user
ENTRYPOINT [ "/entrypoint.sh" ]
CMD ["tail", "-f", "/dev/null"]

View File

@ -46,8 +46,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends ccache && \
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib"
# use login shell to activate environment un the RUN commands
SHELL [ "/bin/bash", "-c", "-l" ]
# Set permissions on /etc/passwd and /home to allow arbitrary users to write
COPY --chown=0:0 docker/build_env/entrypoint.sh /
RUN mkdir -p /home/user && chgrp -R 0 /home && chmod -R g=u /etc/passwd /etc/group /home && chmod +x /entrypoint.sh
# use login shell when running the container
ENTRYPOINT [ "/bin/bash", "-c", "-l" ]
ENV HOME=/home/user
ENTRYPOINT [ "/entrypoint.sh" ]
CMD ["tail", "-f", "/dev/null"]

View File

@ -48,8 +48,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends ccache && \
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib"
# use login shell to activate environment un the RUN commands
SHELL [ "/bin/bash", "-c", "-l" ]
# Set permissions on /etc/passwd and /home to allow arbitrary users to write
COPY --chown=0:0 docker/build_env/entrypoint.sh /
RUN mkdir -p /home/user && chgrp -R 0 /home && chmod -R g=u /etc/passwd /etc/group /home && chmod +x /entrypoint.sh
# use login shell when running the container
ENTRYPOINT [ "/bin/bash", "-c", "-l" ]
ENV HOME=/home/user
ENTRYPOINT [ "/entrypoint.sh" ]
CMD ["tail", "-f", "/dev/null"]

View File

@ -1,45 +0,0 @@
version: '2.3'
services:
cpu_centos7:
image: ${TARGET_REPO}:${TARGET_TAG}
build:
context: ./
dockerfile: cpu/centos7/Dockerfile
cache_from:
- ${SOURCE_REPO}:${SOURCE_TAG}
gpu_centos7:
image: ${TARGET_REPO}:${TARGET_TAG}
build:
context: ./
dockerfile: gpu/centos7/Dockerfile
cache_from:
- ${SOURCE_REPO}:${SOURCE_TAG}
cpu_ubuntu16.04:
image: ${TARGET_REPO}:${TARGET_TAG}
build:
context: ./
dockerfile: cpu/ubuntu16.04/Dockerfile
cache_from:
- ${SOURCE_REPO}:${SOURCE_TAG}
gpu_ubuntu16.04:
image: ${TARGET_REPO}:${TARGET_TAG}
build:
context: ./
dockerfile: gpu/ubuntu16.04/Dockerfile
cache_from:
- ${SOURCE_REPO}:${SOURCE_TAG}
cpu_ubuntu18.04:
image: ${TARGET_REPO}:${TARGET_TAG}
build:
context: ./
dockerfile: cpu/ubuntu18.04/Dockerfile
cache_from:
- ${SOURCE_REPO}:${SOURCE_TAG}
gpu_ubuntu18.04:
image: ${TARGET_REPO}:${TARGET_TAG}
build:
context: ./
dockerfile: gpu/ubuntu18.04/Dockerfile
cache_from:
- ${SOURCE_REPO}:${SOURCE_TAG}

24
docker/build_env/entrypoint.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
set -e
# Ensure $HOME exists when starting
if [ ! -d "${HOME}" ]; then
mkdir -p "${HOME}"
fi
# Setup $PS1 for a consistent and reasonable prompt
if [ -w "${HOME}" ] && [ ! -f "${HOME}"/.bashrc ]; then
echo "PS1='\s-\v \w \$ '" > "${HOME}"/.bashrc
echo -e 'if [ -f /etc/bashrc ]; then\n . /etc/bashrc\nfi' >> "${HOME}"/.bashrc
fi
# Add current (arbitrary) user to /etc/passwd and /etc/group
if ! whoami &> /dev/null; then
if [ -w /etc/passwd ]; then
echo "${USER_NAME:-user}:x:$(id -u):0:${USER_NAME:-user} user:${HOME}:/bin/bash" >> /etc/passwd
echo "${USER_NAME:-user}:x:$(id -u):" >> /etc/group
fi
fi
exec "$@"

View File

@ -38,8 +38,10 @@ RUN yum install -y ccache && \
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib"
# use login shell to activate environment un the RUN commands
SHELL [ "/bin/bash", "-c", "-l" ]
# Set permissions on /etc/passwd and /home to allow arbitrary users to write
COPY --chown=0:0 docker/build_env/entrypoint.sh /
RUN mkdir -p /home/user && chgrp -R 0 /home && chmod -R g=u /etc/passwd /etc/group /home && chmod +x /entrypoint.sh
# use login shell when running the container
ENTRYPOINT [ "/bin/bash", "-c", "-l" ]
ENV HOME=/home/user
ENTRYPOINT [ "/entrypoint.sh" ]
CMD ["tail", "-f", "/dev/null"]

View File

@ -44,8 +44,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends ccache && \
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib"
# use login shell to activate environment un the RUN commands
SHELL [ "/bin/bash", "-c", "-l" ]
# Set permissions on /etc/passwd and /home to allow arbitrary users to write
COPY --chown=0:0 docker/build_env/entrypoint.sh /
RUN mkdir -p /home/user && chgrp -R 0 /home && chmod -R g=u /etc/passwd /etc/group /home && chmod +x /entrypoint.sh
# use login shell when running the container
ENTRYPOINT [ "/bin/bash", "-c", "-l" ]
ENV HOME=/home/user
ENTRYPOINT [ "/entrypoint.sh" ]
CMD ["tail", "-f", "/dev/null"]

View File

@ -44,8 +44,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends ccache && \
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib"
# use login shell to activate environment un the RUN commands
SHELL [ "/bin/bash", "-c", "-l" ]
# Set permissions on /etc/passwd and /home to allow arbitrary users to write
COPY --chown=0:0 docker/build_env/entrypoint.sh /
RUN mkdir -p /home/user && chgrp -R 0 /home && chmod -R g=u /etc/passwd /etc/group /home && chmod +x /entrypoint.sh
# use login shell when running the container
ENTRYPOINT [ "/bin/bash", "-c", "-l" ]
ENV HOME=/home/user
ENTRYPOINT [ "/entrypoint.sh" ]
CMD ["tail", "-f", "/dev/null"]