Skip to content

Commit

Permalink
Add awsim-desktop container
Browse files Browse the repository at this point in the history
  • Loading branch information
doganulus committed May 5, 2024
1 parent f4290c2 commit 386383c
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/awsim-desktop-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build AWSIM desktop container image
on:
workflow_dispatch:
push:
paths:
- awsim-desktop/Dockerfile
- awsim-desktop/entrypoint.sh
- .github/workflows/awsim-desktop-build.yml # Self-trigger

env:
REGISTRY: ghcr.io
IMAGE_NAME: bounverif/awsim-desktop
VERSION: 1.2.1

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to the registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
build-args: |
VERSION=${{ env.VERSION }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
push: true
file: carla/client.dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
36 changes: 36 additions & 0 deletions awsim-desktop/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM ubuntu:22.04 as awsim-downloader

ARG VERSION=1.2.1
ARG AWSIM_VERSION=$VERSION
ARG AWSIM_RELEASE_PATH=https://github.com/tier4/AWSIM/releases/download/v${AWSIM_VERSION}/AWSIM_v${AWSIM_VERSION}.zip
ARG AWSIM_ADDITIONAL_MAPS=https://github.com/tier4/AWSIM/releases/download/v${AWSIM_VERSION}/nishishinjuku_autoware_map.zip

RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install \
wget \
unzip \
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*

RUN wget -qO /tmp/awsim_release.zip ${AWSIM_RELEASE_PATH} && \
unzip /tmp/awsim_release.zip -d /awsim && \
rm /tmp/awsim_release.zip

FROM ghcr.io/selkies-project/nvidia-egl-desktop:22.04 as awsim-desktop

SHELL ["/bin/bash", "-c"]

ARG VERSION=1.2.1
ARG AWSIM_VERSION=$VERSION

ENV TZ=UTC
ENV SIZEW=1920 SIZEH=1080
ENV WEBRTC_ENCODER=nvh264enc
ENV WEBRTC_ENABLE_RESIZE true
ENV ENABLE_BASIC_AUTH false

COPY --from=awsim-downloader --chown=root:root /awsim/AWSIM_v${AWSIM_VERSION} /opt/awsim

COPY entrypoint.sh /etc/entrypoint.sh
RUN sudo chmod +x /etc/entrypoint.sh

EXPOSE 8080
11 changes: 11 additions & 0 deletions awsim-desktop/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Containerized AWSIM simulator

This container is based on `ghcr.io/selkies-project/nvidia-egl-desktop`, which provides a WebRTC solution for containerized GUI apps.

1. First start the container using the following command:

```
docker run --gpus 1 --tmpfs /dev/shm:rw -p 8080:8080 ghcr.io/bounverif/awsim-desktop:1.2.1
```

2. Open a browser and visit `localhost:8080`. The simulator window will appear in the browser. Then you can control the vehicle using the keyboard.
32 changes: 32 additions & 0 deletions awsim-desktop/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash -e

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

trap "echo TRAPed signal" HUP INT QUIT TERM

# Start DBus without systemd
sudo /etc/init.d/dbus start

# Default display is :0 across the container
export DISPLAY=":0"
# Run Xvfb server with required extensions
/usr/bin/Xvfb "${DISPLAY}" -ac -screen "0" "8192x4096x${CDEPTH}" -dpi "${DPI}" +extension "COMPOSITE" +extension "DAMAGE" +extension "GLX" +extension "RANDR" +extension "RENDER" +extension "MIT-SHM" +extension "XFIXES" +extension "XTEST" +iglx +render -nolisten "tcp" -noreset -shmem &

# Wait for X11 to start
echo "Waiting for X socket"
until [ -S "/tmp/.X11-unix/X${DISPLAY/:/}" ]; do sleep 1; done
echo "X socket is ready"

# Resize the screen to the provided size
bash -c ". /opt/gstreamer/gst-env && /usr/local/bin/selkies-gstreamer-resize ${SIZEW}x${SIZEH}"

# Start Fcitx input method framework
/usr/bin/fcitx &

# Add custom processes right below this line, or within `supervisord.conf` to perform service management similar to systemd
exec /opt/awsim/AWSIM.x86_64 -screen-fullscreen &

echo "Session Running. Press [Return] to exit."
read

0 comments on commit 386383c

Please sign in to comment.