Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
Signed-off-by: Oguz Ozturk <oguzkaganozt@gmail.com>
  • Loading branch information
oguzkaganozt committed Jan 30, 2025
1 parent a03da5e commit 9544556
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 53 deletions.
4 changes: 2 additions & 2 deletions docker/docker-bake-tools.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ target "docker-metadata-action-visualizer" {}

target "simulator" {
inherits = ["docker-metadata-action-simulator"]
dockerfile = "docker/tools/Dockerfile"
dockerfile = "docker/tools/Dockerfile.simulator"
target = "simulator"
}

target "visualizer" {
inherits = ["docker-metadata-action-visualizer"]
dockerfile = "docker/tools/Dockerfile"
dockerfile = "docker/tools/Dockerfile.visualizer"
target = "visualizer"
}
57 changes: 6 additions & 51 deletions docker/tools/Dockerfile → docker/tools/Dockerfile.simulator
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ARG ROS_DISTRO

### Builder
FROM ghcr.io/autowarefoundation/autoware:universe-devel AS builder
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO
ARG LIB_DIR
ENV CCACHE_DIR="/root/.ccache"
WORKDIR /autoware
COPY src /autoware/src
Expand Down Expand Up @@ -35,7 +35,9 @@ RUN /autoware/resolve_rosdep_keys.sh /autoware/src/simulator ${ROS_DISTRO} \
&& cat /rosdep-simulator-depend-packages.txt

### Simulator
FROM ghcr.io/autowarefoundation/autoware:universe AS simulator
FROM ghcr.io/autowarefoundation/autoware:universe-visualization-amd64 AS simulator
ARG ROS_DISTRO
ARG LIB_DIR
WORKDIR /autoware
COPY --from=builder /opt/autoware /opt/autoware
COPY --from=builder /rosdep-simulator-depend-packages.txt /tmp/rosdep-simulator-depend-packages.txt
Expand All @@ -49,56 +51,9 @@ RUN --mount=type=ssh \
&& sed -i '/\(xmlschema\|yamale\)/d' /tmp/rosdep-simulator-depend-packages.txt \
&& pip install yamale xmlschema \
&& cat /tmp/rosdep-simulator-depend-packages.txt | xargs apt-get install -y --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* "$HOME"/.cache && \
echo "source /opt/autoware/setup.bash" > /etc/bash.bashrc
&& /autoware/cleanup_system.sh $LIB_DIR $ROS_DISTRO

COPY docker/tools/etc/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["/bin/bash"]

### Visualizer
FROM simulator AS visualizer
WORKDIR /autoware

# Install openbox and VNC requirements
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
curl unzip openbox tigervnc-standalone-server tigervnc-common \
novnc websockify python3-numpy python3-xdg \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# # Set up VNC password
# RUN mkdir -p ~/.vnc && \
# echo "openadkit" | vncpasswd -f > ~/.vnc/passwd && \
# chmod 600 ~/.vnc/passwd

# Create SSL certificate for NoVNC
RUN openssl req -x509 -nodes -newkey rsa:2048 \
-keyout /etc/ssl/private/novnc.key \
-out /etc/ssl/certs/novnc.crt \
-days 365 \
-subj "/O=Autoware-OpenADKit/CN=localhost"

# Install ngrok for optional public access if no public ip available
RUN curl -sSL https://ngrok-agent.s3.amazonaws.com/ngrok.asc \
| tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null && \
echo "deb https://ngrok-agent.s3.amazonaws.com buster main" \
| tee /etc/apt/sources.list.d/ngrok.list && \
apt update && \
apt install ngrok

# Need to expose VNC and NoVNC ports when running the container
EXPOSE 5900 6080

# Add source commands to bash startup
RUN echo "source /opt/ros/$ROS_DISTRO/setup.bash" >> /root/.bashrc && \
echo "source /opt/autoware/setup.bash" >> /root/.bashrc

# Copy startup scripts
COPY docker/tools/etc/xstartup /root/.vnc/xstartup
COPY docker/tools/etc/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh && chmod +x /root/.vnc/xstartup
ENTRYPOINT ["/entrypoint.sh"]
CMD ["/bin/bash"]
88 changes: 88 additions & 0 deletions docker/tools/Dockerfile.visualizer
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
### Builder
FROM ghcr.io/autowarefoundation/autoware:universe-visualization-devel-amd64 AS builder
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV CCACHE_DIR="/root/.ccache"
ARG ROS_DISTRO
WORKDIR /autoware
COPY simulator.repos /autoware/simulator.repos
COPY docker/scripts/resolve_rosdep_keys.sh /autoware/resolve_rosdep_keys.sh
RUN chmod +x /autoware/resolve_rosdep_keys.sh

# Build simulator messages and rviz plugins ONLY
RUN --mount=type=ssh \
--mount=type=cache,target=/var/cache/apt,sharing=locked \
mkdir -p src \
&& vcs import src < simulator.repos \
&& apt-get update \
&& source /opt/ros/"$ROS_DISTRO"/setup.bash && source /opt/autoware/setup.bash \
&& rosdep update && rosdep install -y --from-paths src --ignore-src --rosdistro $ROS_DISTRO \
&& colcon build --cmake-args \
"-Wno-dev" \
"--no-warn-unused-cli" \
--install-base /opt/autoware \
--merge-install \
--mixin release compile-commands ccache \
--base-paths /autoware/src \
--packages-up-to-regex ".*_msgs$" ".*rviz_plugin$" \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* "$HOME"/.cache

# Extract rosdep dependencies for visualizer
RUN source /opt/ros/"$ROS_DISTRO"/setup.bash && source /opt/autoware/setup.bash \
&& /autoware/resolve_rosdep_keys.sh /autoware/src ${ROS_DISTRO} \
| grep -v "yamale\|xmlschema" \
> /rosdep-visualizer-depend-packages.txt \
&& cat /rosdep-visualizer-depend-packages.txt

### Visualizer
FROM ghcr.io/autowarefoundation/autoware:universe-visualization-amd64 AS visualizer
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO
ARG LIB_DIR
ARG VNC_PASSWORD="*"
WORKDIR /autoware

# Get simulator messages, rviz plugins and dependencies
COPY --from=builder /opt/autoware /opt/autoware
COPY --from=builder /rosdep-visualizer-depend-packages.txt /tmp/rosdep-visualizer-depend-packages.txt

# Install openbox, VNC, ngrok, and simulator dependencies

Check warning on line 49 in docker/tools/Dockerfile.visualizer

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (openbox)

Check warning on line 49 in docker/tools/Dockerfile.visualizer

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (ngrok)
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
curl unzip openbox tigervnc-standalone-server tigervnc-common \

Check warning on line 51 in docker/tools/Dockerfile.visualizer

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (openbox)

Check warning on line 51 in docker/tools/Dockerfile.visualizer

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (tigervnc)

Check warning on line 51 in docker/tools/Dockerfile.visualizer

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (tigervnc)
novnc websockify python3-numpy python3-xdg \

Check warning on line 52 in docker/tools/Dockerfile.visualizer

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (novnc)

Check warning on line 52 in docker/tools/Dockerfile.visualizer

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (websockify)
&& curl -sSL https://ngrok-agent.s3.amazonaws.com/ngrok.asc \
| tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null && \

Check warning on line 54 in docker/tools/Dockerfile.visualizer

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (ngrok)
echo "deb https://ngrok-agent.s3.amazonaws.com buster main" \
| tee /etc/apt/sources.list.d/ngrok.list && \

Check warning on line 56 in docker/tools/Dockerfile.visualizer

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (ngrok)
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y ngrok \

Check warning on line 57 in docker/tools/Dockerfile.visualizer

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (ngrok)
# Remove xmlschema and yamale from rosdep packages since we install via pip
&& sed -i '/\(xmlschema\|yamale\)/d' /tmp/rosdep-visualizer-depend-packages.txt \
&& pip install yamale xmlschema \
&& cat /tmp/rosdep-visualizer-depend-packages.txt | xargs apt-get install -y --no-install-recommends \
&& /autoware/cleanup_system.sh $LIB_DIR $ROS_DISTRO

# Set up VNC password
RUN mkdir -p ~/.vnc && \
echo "$VNC_PASSWORD" | vncpasswd -f > ~/.vnc/passwd && \
chmod 600 ~/.vnc/passwd

# Create SSL certificate for NoVNC
RUN openssl req -x509 -nodes -newkey rsa:2048 \
-keyout /etc/ssl/private/novnc.key \
-out /etc/ssl/certs/novnc.crt \
-days 365 \
-subj "/O=Autoware-OpenADKit/CN=localhost"

# Need to expose VNC and NoVNC ports when running the container
EXPOSE 5900 6080

# Add source commands to bash startup
RUN echo "source /opt/ros/$ROS_DISTRO/setup.bash" >> /root/.bashrc && \
echo "source /opt/autoware/setup.bash" >> /root/.bashrc

# Copy startup scripts
COPY docker/tools/etc/xstartup /root/.vnc/xstartup
COPY docker/tools/etc/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh && chmod +x /root/.vnc/xstartup
ENTRYPOINT ["/entrypoint.sh"]
CMD ["/bin/bash"]

0 comments on commit 9544556

Please sign in to comment.