From 4026514ff116ca492fb47086cafd86118e4ce9ae Mon Sep 17 00:00:00 2001 From: "Jeff C. Jensen" <11233838+elgeeko1@users.noreply.github.com> Date: Fri, 2 Aug 2024 10:20:55 -0700 Subject: [PATCH] RTI dockerfile support for multi-architecture builds (#464) * RTI dockerfile support multiarchitecture builds. Use build stage to reduce image size by 20x. Add maintainer documentation to Dockerfile. * Add smoke test for multi-arch docker build * Update core/federated/RTI/rti.Dockerfile Co-authored-by: Shulu Li <65802727+Depetrol@users.noreply.github.com> * Update core/federated/RTI/rti.Dockerfile Co-authored-by: Shulu Li <65802727+Depetrol@users.noreply.github.com> * Update core/federated/RTI/rti.Dockerfile --------- Co-authored-by: Marten Lohstroh Co-authored-by: Shulu Li <65802727+Depetrol@users.noreply.github.com> --- .github/workflows/build-rti.yml | 20 ++++++++++++++++++-- core/federated/RTI/rti.Dockerfile | 17 +++++++++++++---- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-rti.yml b/.github/workflows/build-rti.yml index bcf714ea7..2561b7da0 100644 --- a/.github/workflows/build-rti.yml +++ b/.github/workflows/build-rti.yml @@ -4,7 +4,7 @@ on: workflow_call: jobs: - run: + native-build: strategy: matrix: platform: [ubuntu-latest, macos-latest, windows-latest] @@ -12,8 +12,24 @@ jobs: steps: - name: Check out reactor-c repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Build the RTI with AUTH=OFF run: .github/scripts/build-rti.sh -DAUTH=OFF - name: Build the RTI with AUTH=ON run: .github/scripts/build-rti.sh -DAUTH=ON + + docker-build: + runs-on: ubuntu-latest + steps: + - name: Check out reactor-c repository + uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build Docker image + uses: docker/build-push-action@v6 + with: + file: ./core/federated/RTI/rti.Dockerfile + context: . + platforms: linux/amd64, linux/arm64, linux/arm/v7, linux/riscv64 + push: false + tags: lflang/rti:latest diff --git a/core/federated/RTI/rti.Dockerfile b/core/federated/RTI/rti.Dockerfile index e70e34584..0103abde8 100644 --- a/core/federated/RTI/rti.Dockerfile +++ b/core/federated/RTI/rti.Dockerfile @@ -1,5 +1,5 @@ -# Docker file for building the image of the rti -FROM alpine:latest +ARG BASEIMAGE=alpine:latest +FROM ${BASEIMAGE} as builder COPY . /lingua-franca WORKDIR /lingua-franca/core/federated/RTI RUN set -ex && apk add --no-cache gcc musl-dev cmake make && \ @@ -9,5 +9,14 @@ RUN set -ex && apk add --no-cache gcc musl-dev cmake make && \ make && \ make install -# Use ENTRYPOINT not CMD so that command-line arguments go through -ENTRYPOINT ["RTI"] +WORKDIR /lingua-franca + +# application stage +FROM ${BASEIMAGE} as app +LABEL maintainer="lf-lang" +LABEL source="https://github.com/lf-lang/reactor-c/tree/main/core/federated/RTI" +COPY --from=builder /usr/local/bin/RTI /usr/local/bin/RTI + +WORKDIR /lingua-franca + +ENTRYPOINT ["/usr/local/bin/RTI"]