Skip to content

Commit

Permalink
Add some improvements - to be discussed
Browse files Browse the repository at this point in the history
  • Loading branch information
MSECode committed Dec 29, 2023
1 parent d9ac80b commit b2f43fe
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 36 deletions.
28 changes: 19 additions & 9 deletions dockerfile_images/basic/superbuild-icubhead-withuser/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#start from image passed by argument during build process. Usually it is an ubuntu image plus mesa library.
ARG START_IMG="none"

FROM $START_IMG
FROM $START_IMG AS builder

LABEL maintainer="[email protected], [email protected]"

Expand Down Expand Up @@ -83,8 +83,20 @@ RUN echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-sel
cmake --build . -- ${CMAKE_EXTRA_OPTIONS}


RUN echo "source ${INSTALL_DIR}/share/robotology-superbuild/setup.sh" >> $ROBOTOLOGY_INITIALIZATION_FILE
RUN echo "source ${METADATA_FILE}" >> $ROBOTOLOGY_INITIALIZATION_FILE
RUN echo "source ${INSTALL_DIR}/share/robotology-superbuild/setup.sh" >> $ROBOTOLOGY_INITIALIZATION_FILE &&\
echo "source ${METADATA_FILE}" >> $ROBOTOLOGY_INITIALIZATION_FILE

# Stage 2: secondstage stage
FROM $START_IMG AS secondstage

ARG METADATA_FILE
ARG PROJECTS_DIR
ARG release
ARG sbtag
ARG metadata
ARG INSTALL_DIR="/usr/local"

COPY --from=builder / /

# # The bashrc is read only when opening an interactive shell. Let other projects find packages contained
# # in the superbuild.
Expand All @@ -100,13 +112,11 @@ ENV QT_X11_NO_MITSHM 1
ENV YARP_COLORED_OUTPUT 1



ARG metadata="none"

ENV img_metadata=${metadata}
RUN echo "File metadata = ${METADATA_FILE}"
RUN echo 'export img_metadata=${metadata}' >> $METADATA_FILE
RUN echo 'echo 'This images has release=$release and had been building with superbuild_tag=$sbtag. Metadata=$metadata ' ' >> $METADATA_FILE

RUN echo "File metadata = ${METADATA_FILE}" &&\
echo 'export img_metadata=${metadata}' >> $METADATA_FILE &&\
echo 'echo 'This images has release=$release and had been building with superbuild_tag=$sbtag. Metadata=$metadata ' ' >> $METADATA_FILE


CMD ["bash"]
Expand Down
58 changes: 38 additions & 20 deletions dockerfile_images/basic/superbuild-icubhead/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
#start from image passed by argument during build process. Usually it is an ubuntu image plus mesa library.
ARG START_IMG="none"
ARG METADATA_FILE=/usr/local/bin/setup_metadata.sh
FROM $START_IMG

FROM $START_IMG AS builder

LABEL maintainer="[email protected], [email protected]"

ENV DEBIAN_FRONTEND=noninteractive

# Install dependencies given in documentation in superbuild
# https://github.com/robotology/robotology-superbuild#linux
RUN mkdir /etc/bash_completion.d/ &&\
apt-get update &&\
apt-get install -y \
# MISC
bash-completion \
git


#Some definitions
ARG METADATA_FILE=/usr/local/bin/setup_metadata.sh
ARG PROJECTS_DIR=/projects
ARG CMAKE_GENERATOR="Unix Makefiles"
ARG BUILD_TYPE=Release
Expand All @@ -27,8 +18,21 @@ ARG release
ARG sbtag
ARG metadata
ARG METADATA_FILE
ARG ROBOTOLOGY_INITIALIZATION_FILE=/usr/local/bin/setup_robotology_tdd.sh

# Install dependencies given in documentation in superbuild
# https://github.com/robotology/robotology-superbuild#linux
RUN mkdir /etc/bash_completion.d/ &&\
apt-get update &&\
apt-get install -y \
# MISC
bash-completion \
git


# Setup entrypoint
ARG ROBOTOLOGY_INITIALIZATION_FILE=/usr/local/bin/setup_robotology_tdd.sh
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
COPY setup.sh ${ROBOTOLOGY_INITIALIZATION_FILE}

RUN mkdir ${PROJECTS_DIR} && cd ${PROJECTS_DIR} &&\
git clone https://github.com/robotology/robotology-superbuild.git &&\
Expand All @@ -53,15 +57,28 @@ RUN mkdir ${PROJECTS_DIR} && cd ${PROJECTS_DIR} &&\
cmake --build . --target update-all -- -j4 &&\
cmake --build . -- ${CMAKE_EXTRA_OPTIONS}

# Executing commands in chain makes compilation faster
# other then calling the command RUN everytime
RUN echo "source ${INSTALL_DIR}/share/robotology-superbuild/setup.sh" >> $ROBOTOLOGY_INITIALIZATION_FILE &&\
echo "source ${METADATA_FILE}" >> $ROBOTOLOGY_INITIALIZATION_FILE

# Stage 2: secondstage stage
FROM $START_IMG AS secondstage

RUN echo "source ${INSTALL_DIR}/share/robotology-superbuild/setup.sh" >> $ROBOTOLOGY_INITIALIZATION_FILE
RUN echo "source ${METADATA_FILE}" >> $ROBOTOLOGY_INITIALIZATION_FILE
ARG PROJECTS_DIR
ARG INSTALL_DIR="/usr/local"

COPY --from=builder ${PROJECTS_DIR} ${PROJECTS_DIR}
COPY --from=builder /usr /usr
COPY --from=builder /etc /etc

# The bashrc is read only when opening an interactive shell. Let other projects find packages contained
# in the superbuild.
ENV CMAKE_PREFIX_PATH=${INSTALL_DIR}

# This should theoretically help reducing the size of the final image
FROM scratch
COPY --from=secondstage / /

#The EXPOSE instruction does not actually publish the port.
#It functions as a type of documentation between the person who builds the image and the person who runs the container, about which ports are intended to be published.
Expand All @@ -72,15 +89,16 @@ EXPOSE 10000/tcp 10000/udp
ENV QT_X11_NO_MITSHM 1
ENV YARP_COLORED_OUTPUT 1

ARG metadata="none"
ARG METADATA_FILE
ARG release
ARG sbtag
ARG metadata

ENV img_metadata=${metadata}

RUN echo 'export img_metadata=${metadata}' > $METADATA_FILE
RUN echo 'echo 'This images has release=$release and had been building with superbuild_tag=$sbtag. Metadata=$metadata ' ' >> $METADATA_FILE
RUN echo 'export img_metadata=${metadata}' > $METADATA_FILE &&\
echo 'echo 'This images has release=$release and had been building with superbuild_tag=$sbtag. Metadata=$metadata ' ' >> $METADATA_FILE

COPY entrypoint.sh /usr/local/bin/entrypoint.sh
COPY setup.sh ${ROBOTOLOGY_INITIALIZATION_FILE}
ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ]

CMD ["bash"]
Expand Down
8 changes: 7 additions & 1 deletion dockerfile_images/basic/superbuild-icubtest/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#here add all stuff necessary to run icub-tests
#start from image passed by argument during build process. Usually it is icubteamcode/superbuild:master-unstable_source
ARG SOURCE_IMG="none"
ARG METADATA_FILE="/usr/local/bin/setup_metadata.sh"

# Stage 1: build stage
FROM $SOURCE_IMG as builder

LABEL maintainer="[email protected], [email protected]"

ARG METADATA_FILE="/usr/local/bin/setup_metadata.sh"
ARG INSTALL_DIR="/usr/local"
ARG PROJECTS_DIR=/projects
ARG CMAKE_GENERATOR="Unix Makefiles"
Expand Down Expand Up @@ -53,6 +54,11 @@ RUN cd ${PROJECTS_DIR}/robotology-superbuild &&\
cmake --build . --target update-all -- -j4 &&\
cmake --build . -- ${CMAKE_EXTRA_OPTIONS}

# Stage 2: scratch stage
# This should theoretically help reducing the size of the final image
FROM scratch
COPY --from=secondstage / /

ARG metadata="none"

ENV img_metadata=${metadata}
Expand Down
29 changes: 24 additions & 5 deletions dockerfile_images/basic/superbuild/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#start from image passed by argument during build process. Usually it is an ubuntu image plus mesa library.
ARG START_IMG="none"
ARG METADATA_FILE="/usr/local/bin/setup_metadata.sh"

FROM $START_IMG as builder
# Stage 1: builder stage
FROM $START_IMG AS builder

LABEL maintainer="[email protected], [email protected]"

ARG METADATA_FILE="/usr/local/bin/setup_metadata.sh"
ARG INSTALL_DIR="/usr/local"
ARG PROJECTS_DIR=/projects
ARG CMAKE_GENERATOR="Unix Makefiles"
Expand All @@ -31,6 +32,7 @@ RUN mkdir -p /etc/bash_completion.d/ && \
vim &&\
update-ca-certificates

# Print debug info to check if relevant build args are taken correctly from conf_build.ini
RUN echo "DEBUG ==> Release:" ${release} &&\
echo "DEBUG ==> TAG: " ${tag} &&\
echo "DEBUG ==> metadata: " ${metadata}
Expand Down Expand Up @@ -62,12 +64,25 @@ RUN mkdir ${PROJECTS_DIR} && cd ${PROJECTS_DIR} &&\
# Build all the projects
cmake --build . -- ${CMAKE_EXTRA_OPTIONS} -j5

# This steps should theoretically help cleaning unecessary post-build files that are already installed and that can be eventually re-generated
RUN rm -rf ${PROJECTS_DIR}/robotology-superbuild/build/src &&\
echo "source ${INSTALL_DIR}/share/robotology-superbuild/setup.sh" >> $ROBOTOLOGY_INITIALIZATION_FILE


# NEW STAGE ######
FROM $START_IMG as secondstage
# Do we still need this repo from appsAway??
# RUN cd ${PROJECTS_DIR} && \
# git clone https://github.com/icub-tech-iit/appsAway.git && \
# cd appsAway/modules/checkRobotInterface && \
# mkdir build && cd build && \
# cmake .. \
# -G "$CMAKE_GENERATOR" \
# -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
# &&\
# cmake --build . -- ${CMAKE_EXTRA_OPTIONS} && \
# cp ./checkRobotInterface /usr/local/bin

# Stage 2: secondstage stage
FROM $START_IMG AS secondstage

# Setup entrypoint
ARG ROBOTOLOGY_INITIALIZATION_FILE=/usr/local/bin/setup_robotology_tdd.sh
Expand All @@ -87,8 +102,12 @@ RUN echo 'export img_metadata=${metadata}' > ${METADATA_FILE} &&\

RUN echo "source ${METADATA_FILE}" >> ${ROBOTOLOGY_INITIALIZATION_FILE}

# COPY --from=secondstage / /
# This should theoretically help reducing the size of the final image
FROM scratch

ARG metadata

COPY --from=secondstage / /

#The EXPOSE instruction does not actually publish the port.
#It functions as a type of documentation between the person who builds the image and the person who runs the container, about which ports are intended to be published.
Expand Down
2 changes: 1 addition & 1 deletion dockerfile_images/basic/superbuild/Dockerfile4Production
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ARG START_IMG="none"
ARG SOURCE_IMG="none"

FROM $SOURCE_IMG AS builder
FROM $START_IMG as secondstage
FROM $START_IMG AS secondstage

LABEL maintainer="[email protected], [email protected]"

Expand Down

0 comments on commit b2f43fe

Please sign in to comment.