Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docker): add simulator-visualizer container #5411

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
docker
!docker/etc
!docker/scripts
!docker/tools

# Ignore a part of files under src
src/**/.*
Expand Down
110 changes: 110 additions & 0 deletions .github/actions/docker-build-and-push-tools/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: docker-build-and-push-tools
description: Composite action to build and push tools images to registry.

inputs:
platform:
description: Target platform.
required: true
target-image:
description: Target docker image name in the registry.
required: true
build-args:
description: Additional build args.
required: false

runs:
using: composite
steps:
- name: Install jq and vcstool
run: |
sudo apt-get -y update
sudo apt-get -y install jq python3-pip
pip install --no-cache-dir vcstool
shell: bash

- name: Run vcs import
run: |
mkdir src
vcs import src < autoware.repos
shell: bash

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Restore ccache
uses: actions/cache/restore@v4
with:
path: |
root-ccache
key: ccache-${{ inputs.platform }}-${{ hashFiles('src/**/*.cpp') }}
restore-keys: |
ccache-${{ inputs.platform }}-

- name: Restore apt-get
uses: actions/cache/restore@v4
with:
path: |
var-cache-apt
key: apt-get-${{ inputs.platform }}-${{ hashFiles('src/**/package.xml') }}
restore-keys: |
apt-get-${{ inputs.platform }}-

- name: Inject cache into docker
uses: reproducible-containers/[email protected]
with:
cache-map: |
{
"root-ccache": "/root/.ccache",
"var-cache-apt": "/var/cache/apt"
}
skip-extraction: true

- name: Get current date
id: date
run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
shell: bash

- name: Docker meta for autoware:visualizer
id: meta-visualizer
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/${{ inputs.target-image }}
tags: |
type=raw,value=visualizer-${{ inputs.platform }}
type=raw,value=visualizer-${{ steps.date.outputs.date }}-${{ inputs.platform }}
type=ref,event=tag,prefix=visualizer-,suffix=-${{ inputs.platform }}
bake-target: docker-metadata-action-visualizer
flavor: |
latest=false

- name: Docker meta for autoware:simulator
id: meta-simulator
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/${{ inputs.target-image }}
tags: |
type=raw,value=simulator-${{ inputs.platform }}
type=raw,value=simulator-${{ steps.date.outputs.date }}-${{ inputs.platform }}
type=ref,event=tag,prefix=simulator-,suffix=-${{ inputs.platform }}
bake-target: docker-metadata-action-simulator
flavor: |
latest=false

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}

- name: Build and Push to GitHub Container Registry
uses: docker/bake-action@v5
with:
push: true
files: |
docker/docker-bake-tools.hcl
${{ steps.meta-simulator.outputs.bake-file }}
${{ steps.meta-visualizer.outputs.bake-file }}
provenance: false
set: |
${{ inputs.build-args }}
29 changes: 29 additions & 0 deletions .github/actions/docker-build-and-push/action.yaml
oguzkaganozt marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,32 @@ runs:
flavor: |
latest=false

- name: Docker meta for autoware:visualizer
id: meta-visualizer
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/${{ inputs.target-image }}
tags: |
type=raw,value=visualizer-${{ inputs.platform }}
type=raw,value=visualizer-${{ steps.date.outputs.date }}-${{ inputs.platform }}
type=ref,event=tag,prefix=visualizer-,suffix=-${{ inputs.platform }}
bake-target: docker-metadata-action-visualizer
flavor: |
latest=false

- name: Docker meta for autoware:simulator
id: meta-simulator
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/${{ inputs.target-image }}
tags: |
type=raw,value=simulator-${{ inputs.platform }}
type=raw,value=simulator-${{ steps.date.outputs.date }}-${{ inputs.platform }}
type=ref,event=tag,prefix=simulator-,suffix=-${{ inputs.platform }}
bake-target: docker-metadata-action-simulator
flavor: |
latest=false

- name: Docker meta for autoware:universe-devel
id: meta-universe-devel
uses: docker/metadata-action@v5
Expand Down Expand Up @@ -220,6 +246,7 @@ runs:
push: true
files: |
docker/docker-bake.hcl
docker/docker-bake-tools.hcl
${{ steps.meta-core-devel.outputs.bake-file }}
${{ steps.meta-universe-sensing-perception-devel.outputs.bake-file }}
${{ steps.meta-universe-sensing-perception.outputs.bake-file }}
Expand All @@ -231,6 +258,8 @@ runs:
${{ steps.meta-universe-vehicle-system.outputs.bake-file }}
${{ steps.meta-universe-devel.outputs.bake-file }}
${{ steps.meta-universe.outputs.bake-file }}
${{ steps.meta-simulator.outputs.bake-file }}
${{ steps.meta-visualizer.outputs.bake-file }}
provenance: false
set: |
${{ inputs.build-args }}
16 changes: 16 additions & 0 deletions .github/workflows/docker-build-and-push-arm64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,22 @@ jobs:
*.cache-from=type=registry,ref=ghcr.io/${{ github.repository }}-buildcache:arm64-main
*.cache-to=type=registry,ref=ghcr.io/${{ github.repository }}-buildcache:arm64-${{ github.ref_name }},mode=max

- name: Build 'Tools'
uses: ./.github/actions/docker-build-and-push-tools
with:
platform: arm64
target-image: autoware-tools
build-args: |
*.platform=linux/arm64
*.args.ROS_DISTRO=${{ needs.load-env.outputs.rosdistro }}
*.args.BASE_IMAGE=${{ needs.load-env.outputs.base_image }}
*.args.AUTOWARE_BASE_IMAGE=${{ needs.load-env.outputs.autoware_base_image }}
*.args.AUTOWARE_BASE_CUDA_IMAGE=${{ needs.load-env.outputs.autoware_base_cuda_image }}
*.args.LIB_DIR=aarch64
*.cache-from=type=registry,ref=ghcr.io/${{ github.repository }}-buildcache:arm64-${{ github.ref_name }}
*.cache-from=type=registry,ref=ghcr.io/${{ github.repository }}-buildcache:arm64-main
*.cache-to=type=registry,ref=ghcr.io/${{ github.repository }}-buildcache:arm64-${{ github.ref_name }},mode=max

- name: Show disk space
if: always()
run: |
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/docker-build-and-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,22 @@ jobs:
*.cache-from=type=registry,ref=ghcr.io/${{ github.repository }}-buildcache:amd64-main
*.cache-to=type=registry,ref=ghcr.io/${{ github.repository }}-buildcache:amd64-${{ github.ref_name }},mode=max

- name: Build 'Tools'
uses: ./.github/actions/docker-build-and-push-tools
with:
platform: amd64
target-image: autoware-tools
build-args: |
*.platform=linux/amd64
*.args.ROS_DISTRO=${{ needs.load-env.outputs.rosdistro }}
*.args.BASE_IMAGE=${{ needs.load-env.outputs.base_image }}
*.args.AUTOWARE_BASE_IMAGE=${{ needs.load-env.outputs.autoware_base_image }}
*.args.AUTOWARE_BASE_CUDA_IMAGE=${{ needs.load-env.outputs.autoware_base_cuda_image }}
*.args.LIB_DIR=x86_64
*.cache-from=type=registry,ref=ghcr.io/${{ github.repository }}-buildcache:amd64-${{ github.ref_name }}
*.cache-from=type=registry,ref=ghcr.io/${{ github.repository }}-buildcache:amd64-main
*.cache-to=type=registry,ref=ghcr.io/${{ github.repository }}-buildcache:amd64-${{ github.ref_name }},mode=max

- name: Show disk space
if: always()
run: |
Expand Down
22 changes: 22 additions & 0 deletions docker/docker-bake-tools.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
group "default" {
targets = [
"simulator",
"visualizer"
]
}

// For docker/metadata-action
target "docker-metadata-action-simulator" {}
target "docker-metadata-action-visualizer" {}

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

target "visualizer" {
inherits = ["docker-metadata-action-visualizer"]
dockerfile = "docker/tools/Dockerfile"
target = "visualizer"
}
104 changes: 104 additions & 0 deletions docker/tools/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
ARG ROS_DISTRO

### Builder
FROM ghcr.io/autowarefoundation/autoware:universe-devel AS builder
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV CCACHE_DIR="/root/.ccache"
WORKDIR /autoware
COPY src /autoware/src
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

# Install dependencies and build the simulator
RUN --mount=type=ssh \
--mount=type=cache,target=/var/cache/apt,sharing=locked \
vcs import src < simulator.repos \
&& apt-get update \
&& rosdep update && rosdep install -y --from-paths src --ignore-src --rosdistro $ROS_DISTRO \
&& source /opt/ros/"$ROS_DISTRO"/setup.bash && source /opt/autoware/setup.bash \
&& 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/simulator \
&& find /opt/autoware/lib -type f -name "*.py" -exec chmod +x {} \; \
&& find /opt/autoware/share -type f -name "*.py" -exec chmod +x {} \; \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* "$HOME"/.cache

# Extract rosdep dependencies for simulator
RUN /autoware/resolve_rosdep_keys.sh /autoware/src/simulator ${ROS_DISTRO} \
> /rosdep-simulator-depend-packages.txt \
&& cat /rosdep-simulator-depend-packages.txt

### Simulator
FROM ghcr.io/autowarefoundation/autoware:universe AS simulator
WORKDIR /autoware
COPY --from=builder /opt/autoware /opt/autoware
COPY --from=builder /rosdep-simulator-depend-packages.txt /tmp/rosdep-simulator-depend-packages.txt

RUN --mount=type=ssh \
--mount=type=cache,target=/var/cache/apt,sharing=locked \
apt-get update && apt-get install -y curl unzip \
&& source /opt/ros/"$ROS_DISTRO"/setup.bash && source /opt/autoware/setup.bash \
&& rosdep update \
# Remove xmlschema and yamale from rosdep packages since we install via pip
&& 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

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

Check warning on line 65 in docker/tools/Dockerfile

View workflow job for this annotation

GitHub Actions / spell-check-differential

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

Check warning on line 67 in docker/tools/Dockerfile

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (openbox)

Check warning on line 67 in docker/tools/Dockerfile

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (tigervnc)

Check warning on line 67 in docker/tools/Dockerfile

View workflow job for this annotation

GitHub Actions / spell-check-differential

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

Check warning on line 68 in docker/tools/Dockerfile

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (novnc)

Check warning on line 68 in docker/tools/Dockerfile

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (websockify)
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

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

Check warning on line 74 in docker/tools/Dockerfile

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (vncpasswd)
# chmod 600 ~/.vnc/passwd

Comment on lines +72 to +76
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please delete them if you don't need. You can revert them from this PR when you will need.

# Create SSL certificate for NoVNC
RUN openssl req -x509 -nodes -newkey rsa:2048 \

Check warning on line 78 in docker/tools/Dockerfile

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (newkey)
-keyout /etc/ssl/private/novnc.key \

Check warning on line 79 in docker/tools/Dockerfile

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (keyout)

Check warning on line 79 in docker/tools/Dockerfile

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (novnc)
-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"]
Loading
Loading