Skip to content

Commit de223ff

Browse files
committed
Create an entrypoint script for Docker service
1 parent 579c7af commit de223ff

3 files changed

Lines changed: 42 additions & 3 deletions

File tree

‎Dockerfile‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
FROM ubuntu:latest
22

3+
RUN mkdir /opt/source
4+
RUN mkdir /opt/workdir
5+
36
RUN apt-get -y update
47
RUN apt-get -y install \
58
clang++-22 \
@@ -22,12 +25,23 @@ RUN rustup component add --toolchain "1.96.1-x86_64-unknown-linux-gnu" rust-src
2225
ENV PATH="/root/.cargo/bin:${PATH}"
2326
ENV RUST_BACKTRACE=full
2427

25-
WORKDIR /opt/workdir
28+
COPY cpp2rust /opt/source/cpp2rust
29+
COPY libc-dep /opt/source/libc-dep
30+
COPY libcc2rs /opt/source/libcc2rs
31+
COPY libcc2rs-macros /opt/source/libcc2rs-macros
32+
COPY cmake /opt/source/cmake
33+
COPY tests /opt/source/tests
34+
35+
COPY CMakeLists.txt /opt/source/CMakeLists.txt
2636

27-
CMD cmake \
37+
WORKDIR /opt/source
38+
39+
RUN cmake \
2840
-G Ninja \
2941
-B build \
3042
-D CMAKE_C_COMPILER="$(which clang-22)" \
3143
-D CMAKE_CXX_COMPILER="$(which clang++-22)" \
3244
.; \
3345
cmake --build build -j$(nproc)
46+
47+
WORKDIR /opt/workdir

‎compose.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ services:
55
context: .
66
volumes:
77
- "$PWD:/opt/workdir"
8-
8+
entrypoint: ./misc/containers/build.sh

‎misc/containers/build.sh‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env sh
2+
3+
# DO NOT RUN!
4+
# This image is intended to be used from an OCI compose file.
5+
6+
set -eo pipefail
7+
8+
if [ -d "/opt/workdir/build" ]; then
9+
echo "Build directory already exists, moving it."
10+
if [ -d "/opt/workdir/build-backup" ]; then
11+
echo "Build backup directory already exists, exiting as error."
12+
exit 1
13+
else
14+
mv /opt/workdir/build /opt/workdir/build-backup
15+
fi
16+
fi
17+
18+
cmake \
19+
-G Ninja \
20+
-B build \
21+
-D CMAKE_C_COMPILER="$(which clang-22)" \
22+
-D CMAKE_CXX_COMPILER="$(which clang++-22)" \
23+
.
24+
25+
cmake --build build "-j$(nproc)"

0 commit comments

Comments
 (0)