Skip to content

Commit

Permalink
build: copy python packages into /usr instead of ~ros2 to avoid permi…
Browse files Browse the repository at this point in the history
…ssion issues (#69)
  • Loading branch information
LouisBrunner authored Feb 20, 2024
1 parent d0c5ef7 commit 1c76cbd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Release Versions:

## Upcoming changes (in development)

- build: copy python packages into /usr instead of ~ros2 to avoid permission issues (#69)
- feat: add is_opened flag to socket base class (#68)

## 2.0.1
Expand Down
14 changes: 6 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,15 @@ COPY --from=install /tmp/communication-interfaces /usr
COPY --chown=${USER}:${USER} ./python /python
RUN --mount=type=cache,target=${HOME}/.cache,id=pip-${TARGETPLATFORM}-${CACHEID},uid=1000 \
python3 -m pip install --prefix=/tmp/python /python
RUN mkdir -p /tmp/python-home/${USER}/.local/lib/python3.10/ \
&& mv /tmp/python/local/lib/python3.10/dist-packages/ /tmp/python-home/${USER}/.local/lib/python3.10/site-packages/
RUN mv /tmp/python/local /tmp/python-usr

FROM build as test
ARG TARGETPLATFORM
ARG CACHEID
RUN --mount=type=cache,target=./build,id=cmake-${TARGETPLATFORM}-${CACHEID},uid=1000 \
cmake -B build -DBUILD_TESTING=ON && cd build && make && CTEST_OUTPUT_ON_FAILURE=1 make test
COPY --from=install /tmp/communication-interfaces /usr/local
COPY --from=python /tmp/python-home/ /home
COPY --from=python /tmp/python-usr /usr
COPY --from=python /python/test /python/test
RUN python3 -m pytest /python/test --verbose

Expand All @@ -98,7 +97,7 @@ ARG TARGETPLATFORM
ARG CACHEID
COPY --from=apt-dependencies /tmp/apt /
COPY --from=install /tmp/communication-interfaces /usr
COPY --from=python /tmp/python-home /home
COPY --from=python /tmp/python-usr /usr
RUN sudo pip install pybind11-stubgen
RUN --mount=type=cache,target=${HOME}/.cache,id=pip-${TARGETPLATFORM}-${CACHEID},uid=1000 \
<<HEREDOC
Expand All @@ -125,11 +124,10 @@ EoF
rm -r ./stubs
fi
HEREDOC
RUN mkdir -p /tmp/python-home/${USER}/.local/lib/python3.10/ \
&& mv /tmp/python/local/lib/python3.10/dist-packages/ /tmp/python-home/${USER}/.local/lib/python3.10/site-packages/
RUN mv /tmp/python/local /tmp/python-usr

FROM scratch as production
COPY --from=apt-dependencies /tmp/apt /
COPY --from=install /tmp/communication-interfaces /usr/local
COPY --from=python /tmp/python-home/ /home
COPY --from=python-stubs /tmp/python-home /home
COPY --from=python /tmp/python-usr /usr
COPY --from=python-stubs /tmp/python-usr /usr

0 comments on commit 1c76cbd

Please sign in to comment.