Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/build_config/docker/Dockerfile.ubuntu.git
193833 views
# to build this image run the following command
# $ docker build -t sumo - < Dockerfile.ubuntu.git
# to use it run (GUI applications need more work)
# $ docker run -it sumo bash
# now you have a bash inside a docker container and can for instance run
# $ cd /opt/sumo; bin/sumo -c docs/examples/sumo/busses/test.sumocfg
# This Dockerfile installs everything for a full fledged SUMO with all tools runnable.
# If you don't need certain features and rather have a smaller container you can comment the unneeded parts below

# We are dividing the build into multiple stages to reduce the size of the resulting image
FROM ubuntu:jammy AS build

ENV SUMO_HOME=/usr/share/sumo
ARG DEBIAN_FRONTEND=noninteractive
ARG JUPEDSIM_VERSION=1.3.1

RUN apt-get -qq update && \
    apt-get -y install git ca-certificates lsb-release wget

RUN cd /opt; git clone --shallow-submodules --single-branch --recursive https://github.com/eclipse-sumo/sumo

# installing dependencies
RUN apt-get -y install $(cat /opt/sumo/build_config/build_req_deb.txt) && \
    apt-get -y install libavformat-dev libopenscenegraph-dev libswscale-dev && \
    wget https://packages.apache.org/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb && \
    apt-get -y install ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb && \
    rm ./apache-arrow-apt-source-latest-*.deb && \
    apt-get -qq update && \
    apt-get -y install libarrow-dev libparquet-dev && \
    apt-get -y install $(cat /opt/sumo/build_config/tools_req_deb.txt) && \
    pip3 install --no-cache-dir -r /opt/sumo/tools/requirements.txt -r /opt/sumo/docs/web/requirements.txt

# JuPedSim build
RUN cd /opt && \
    wget -q https://github.com/PedestrianDynamics/jupedsim/archive/refs/tags/v$JUPEDSIM_VERSION.tar.gz && \
    tar xzf v$JUPEDSIM_VERSION.tar.gz && \
    cmake -B jupedsim-build -D CMAKE_INSTALL_PREFIX=/install/usr jupedsim-${JUPEDSIM_VERSION} && \
    cmake --build jupedsim-build -j$(nproc) && \
    cmake --install jupedsim-build && \
    rm -rf /opt/jupedsim-$JUPEDSIM_VERSION /opt/jupedsim-build v$JUPEDSIM_VERSION.tar.gz

# SUMO build
RUN cd /opt/sumo && \
    cmake -B cmake-build -DCMAKE_INSTALL_PREFIX=/install/usr -DSUMO_UTILS=TRUE && \
    cmake --build cmake-build -j$(nproc) --target all --target examples --target doc && \
    cmake --install cmake-build && \
    rm -rf cmake-build

# Now create actual image
FROM ubuntu:jammy

# Add metadata
LABEL org.opencontainers.image.authors="SUMO Developers <[email protected]>" \
      org.opencontainers.image.url="https://ghcr.io/eclipse-sumo/sumo" \
      org.opencontainers.image.source="https://github.com/eclipse-sumo/sumo/blob/main/build_config/docker/Dockerfile.ubuntu.git" \
      org.opencontainers.image.documentation="https://sumo.dlr.de/docs/Developer/Docker.html" \
      org.opencontainers.image.licenses="EPL-2.0 OR GPL-2.0-or-later"

# Setup environment
ENV SUMO_HOME=/usr/share/sumo
ARG DEBIAN_FRONTEND=noninteractive
ARG ARROW_VERSION=2200

# Getting build artifacts
COPY --from=build /install/usr /usr
# Get dependency lists
COPY --from=build /opt/sumo/build_config/build_req_deb.txt /tmp/build_req_deb.txt
COPY --from=build /opt/sumo/build_config/tools_req_deb.txt /tmp/tools_req_deb.txt
COPY --from=build /opt/sumo/tools/requirements.txt /tmp/requirements.txt

# Installing runtime dependencies (for simplicity we use the build dependencies. Possibility for optimization in the future)
RUN apt-get -qq update && \
    apt-get -y install git ca-certificates lsb-release wget && \
    wget https://packages.apache.org/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb && \
    apt-get -y install ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb && \
    apt-get -qq update && \
    apt-get -qq -y install $(cat /tmp/build_req_deb.txt) $(cat /tmp/tools_req_deb.txt) \
                           libavformat58 libopenscenegraph161 libswscale5 libarrow$ARROW_VERSION libparquet$ARROW_VERSION && \
    apt-get -qq clean autoclean && \
    apt-get -qq -y autoremove && \
    rm -rf /var/lib/apt/lists/*

# Installing tools dependencies for python
RUN pip3 install --no-cache-dir -r /tmp/requirements.txt

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