Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 5 additions & 32 deletions .github/workflows/build-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ permissions:
packages: write

env:
ContainerRegistry: "ghcr.io"
ContainerRegistry: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
Expand All @@ -32,41 +32,14 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# -------- Build and Push: Server --------
- name: Build and push Server multi-arch image
- name: Build and push multi-arch image (agent + server + player)
uses: docker/build-push-action@v6
with:
context: .
file: containers/Dockerfile
file: containers/Dockerfile1 # Your updated Dockerfile
Comment thread
akshaylg0314 marked this conversation as resolved.
platforms: linux/amd64,linux/arm64
push: true
build-args: |
COMPONENT=server
TARGETARCH
tags: ${{ env.ContainerRegistry }}/${{ env.IMAGE_NAME }}-server:${{ github.ref_name }}

# -------- Build and Push: Agent --------
- name: Build and push Agent multi-arch image
uses: docker/build-push-action@v6
with:
context: .
file: containers/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
build-args: |
COMPONENT=agent
TARGETARCH
tags: ${{ env.ContainerRegistry }}/${{ env.IMAGE_NAME }}-agent:${{ github.ref_name }}

# -------- Build and Push: Player --------
- name: Build and push Player multi-arch image
uses: docker/build-push-action@v6
with:
context: .
file: containers/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
build-args: |
COMPONENT=player
TARGETARCH
tags: ${{ env.ContainerRegistry }}/${{ env.IMAGE_NAME }}-player:${{ github.ref_name }}
tags: |
${{ env.ContainerRegistry }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}
73 changes: 39 additions & 34 deletions containers/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,39 @@
# SPDX-FileCopyrightText: Copyright 2024 LG Electronics Inc.
# SPDX-License-Identifier: Apache-2.0

############################
#################################
# === Build Stage ===
############################
#################################
FROM rust:1.85.0-slim AS builder

ARG COMPONENT
ARG TARGETARCH

ENV COMPONENT=${COMPONENT}
ENV TARGETARCH=${TARGETARCH}
WORKDIR /piccolo

WORKDIR /pullpiri
# Copy shared source and both components
COPY ./src/common/ /piccolo/common/
COPY ./src/server/ /piccolo/server/
COPY ./src/agent/ /piccolo/agent/
COPY ./src/player/ /piccolo/player

# Copy shared and component-specific source code into container
COPY ./src/common /pullpiri/common
COPY ./src/${COMPONENT} /pullpiri/${COMPONENT}

# Install necessary libraries and build component
# Install build dependencies
RUN apt update -y && \
apt install -y \
libdbus-1-dev \
pkg-config \
protobuf-compiler \
libssl-dev && \
cd /pullpiri/${COMPONENT} && \
cargo build --release

# Prepare glibc shared libraries for static alpine runtime
apt install -y libdbus-1-dev pkg-config protobuf-compiler libssl-dev

# Build server binaries
WORKDIR /piccolo/server
RUN cargo build --release

# Build agent binaries
WORKDIR /piccolo/agent
RUN cargo build --release

# Build player binaries
WORKDIR /piccolo/player
RUN cargo build --release

# Prepare glibc shared libraries
WORKDIR /dummy
RUN if [ "$TARGETARCH" = "amd64" ]; then \
ITEMARCH="x86_64"; \
Expand All @@ -40,8 +45,6 @@ RUN if [ "$TARGETARCH" = "amd64" ]; then \
mkdir -p /dummy/${ITEMARCH}-linux-gnu/ && \
cp -v /lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 /dummy/${ITEMARCH}-linux-gnu/ || true && \
cp -v /lib/ld-linux-aarch64.so.1 /dummy/ || true; \
else \
echo "Unsupported architecture: $TARGETARCH" && exit 1; \
fi && \
for lib in \
libc.so.6 libcap.so.2 libdbus-1.so.3 libgcc_s.so.1 \
Expand All @@ -50,23 +53,20 @@ RUN if [ "$TARGETARCH" = "amd64" ]; then \
cp -v /lib/${ITEMARCH}-linux-gnu/$lib* /dummy/${ITEMARCH}-linux-gnu/ || true; \
done

############################
#################################
# === Runtime Stage ===
############################
#################################
FROM alpine:3.21.3

ARG COMPONENT
ARG TARGETARCH

ENV COMPONENT=${COMPONENT}
ENV TARGETARCH=${TARGETARCH}

WORKDIR /pullpiri
WORKDIR /piccolo

# Copy runtime shared libraries
# Copy shared libraries
COPY --from=builder /dummy /lib

# Ensure dynamic linker is in correct place for glibc-based binaries
# Setup dynamic linker for glibc
RUN if [ "$TARGETARCH" = "amd64" ]; then \
mkdir -p /lib64 && \
cp -v /lib/lib64/ld-linux-x86-64.so.2 /lib64/ || true; \
Expand All @@ -76,11 +76,16 @@ RUN if [ "$TARGETARCH" = "amd64" ]; then \
echo "Unsupported architecture: $TARGETARCH" && exit 1; \
fi

# Copy built Rust binary
COPY --from=builder /pullpiri/${COMPONENT}/target/release/ /pullpiri/
# Copy built binaries
COPY --from=builder /piccolo/server/target/release/apiserver /piccolo/
COPY --from=builder /piccolo/server/target/release/monitoringserver /piccolo/
COPY --from=builder /piccolo/server/target/release/policymanager /piccolo/
COPY --from=builder /piccolo/agent/target/release/nodeagent /piccolo/
COPY --from=builder /piccolo/player/target/release/actioncontroller /piccolo/
COPY --from=builder /piccolo/player/target/release/filtergateway /piccolo/
COPY --from=builder /piccolo/player/target/release/statemanager /piccolo/

# Copy shared runtime config
# Copy runtime settings
COPY ./src/settings.yaml .

# Entry point
CMD ["sh"]
CMD [ "sh" ]