Skip to content

Commit

Permalink
Merge branch 'main' into me/uniformCsharpNamespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
melflitty-aneo authored Aug 11, 2023
2 parents 6bc6431 + 6814e0c commit 8815951
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 97 deletions.
10 changes: 2 additions & 8 deletions packages/cpp/ArmoniK.Api.Common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ set(CMAKE_FIND_DEBUG_MODE FALSE)
find_package(Protobuf REQUIRED)
find_package(gRPC CONFIG REQUIRED)
find_package(Threads)
find_package(fmt CONFIG REQUIRED)

include(FetchContent)

Expand All @@ -45,12 +46,6 @@ if(NOT simdjson_POPULATED)
FetchContent_Populate(simdjson)
endif()

FetchContent_Declare(
fmt
URL https://github.com/fmtlib/fmt/archive/refs/tags/10.0.0.tar.gz
)
FetchContent_MakeAvailable(fmt)

set(CMAKE_FIND_DEBUG_MODE FALSE)

SET(SOURCES_FILES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/source")
Expand All @@ -63,8 +58,7 @@ file(MAKE_DIRECTORY ${PROJECT_BUILD_DIR})

add_library(${PROJECT_NAME} STATIC ${PROTO_GENERATED_FILES} ${SRC_CLIENT_FILES} ${HEADER_CLIENT_FILES} ${simdjson_SOURCE_DIR}/singleheader/simdjson.cpp ${simdjson_SOURCE_DIR}/singleheader/simdjson.h)

target_link_libraries(${PROJECT_NAME} PUBLIC protobuf::libprotobuf gRPC::grpc++_unsecure)
target_link_libraries(${PROJECT_NAME} PRIVATE fmt::fmt)
target_link_libraries(${PROJECT_NAME} PUBLIC protobuf::libprotobuf gRPC::grpc++_unsecure fmt::fmt)
target_compile_definitions(${PROJECT_NAME} PUBLIC API_COMMON_NAMESPACE=${NAMESPACE})

setup_options(${PROJECT_NAME})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class PlainFormatter : public IFormatter {
};

std::unique_ptr<IFormatter> formatter_clef() { return std::make_unique<ClefFormatter>(); }
std::unique_ptr<IFormatter> formatter_clef(bool styling) { return std::make_unique<PlainFormatter>(styling); }
std::unique_ptr<IFormatter> formatter_plain(bool styling) { return std::make_unique<PlainFormatter>(styling); }

// Interface destructor
IFormatter::~IFormatter() = default;
Expand Down
1 change: 1 addition & 0 deletions packages/cpp/tools/BuildEnv.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ RUN apt-get update && DEBIAN_FRONTEND="noninteractive" TZ="Europe/London" apt-ge
libgrpc-dev \
libgrpc++-dev \
libprotobuf-dev \
libfmt-dev \
&& apt-get clean

ENV protobuf_BUILD_TESTS=OFF
Expand Down
3 changes: 2 additions & 1 deletion packages/cpp/tools/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ RUN apt-get update && DEBIAN_FRONTEND="noninteractive" TZ="Europe/London" apt-ge
protobuf-compiler-grpc \
grpc-proto \
libgrpc-dev \
libgrpc++-dev
libgrpc++-dev \
libfmt-dev

# Set environment variables for protobuf
ENV protobuf_BUILD_TESTS=OFF
Expand Down
175 changes: 88 additions & 87 deletions packages/cpp/tools/Dockerfile.worker
Original file line number Diff line number Diff line change
@@ -1,87 +1,88 @@
# Start with the latest Alpine base image for the build stage
FROM alpine AS builder
ARG GRPC_VERSION=v1.54.0

# Install all the necessary dependencies required for the build process
# These include tools and libraries for building and compiling the source code
RUN apk update && apk add --no-cache \
git \
gcc \
g++ \
build-base \
autoconf \
automake \
libtool \
curl \
c-ares \
c-ares-dev \
make \
cmake \
unzip \
linux-headers \
grpc \
grpc-dev \
protobuf \
protobuf-dev

# Update the PATH environment variable to include the gRPC libraries and binaries
ENV LD_LIBRARY_PATH="/app/install/lib:$LD_LIBRARY_PATH"
ENV PATH="/app/install/bin:$PATH"

# Display the updated PATH environment variable
RUN echo $PATH

# Copy the application source files into the image
WORKDIR /app/source
COPY ./packages/cpp/ArmoniK.Api.Common ./ArmoniK.Api.Common
COPY ./packages/cpp/ArmoniK.Api.Worker ./ArmoniK.Api.Worker
COPY ./packages/cpp/ArmoniK.Api.Worker.Tests ./ArmoniK.Api.Worker.Tests
COPY ./packages/cpp/CMakeLists.txt ./

# Copy the Protocol Buffer definition files into the image
WORKDIR /app/proto
COPY ./Protos/V1/ /app/proto

# Build the application using the copied source files and protobuf definitions
WORKDIR /app/builder
RUN cmake -DCMAKE_INSTALL_PREFIX="/app/install" -DPROTO_FILES_DIR="/app/proto" -DBUILD_TEST=ON -DBUILD_CLIENT=OFF -DBUILD_WORKER=ON /app/source/
RUN make -j $(nproc) install

# Start with the latest Alpine base image for the final stage
FROM alpine
# Install all the necessary dependencies required for the build process
# These include tools and libraries for building and compiling the source code
RUN apk update && apk add --no-cache \
git \
gcc \
g++ \
build-base \
autoconf \
automake \
libtool \
curl \
c-ares \
c-ares-dev \
make \
cmake \
unzip \
linux-headers \
libprotobuf \
grpc \
grpc-cpp

# Create a non-root user and group for running the application
# This is a security best practice to avoid running applications as the root user
RUN addgroup -g 5000 -S armonikuser && adduser -D -h /home/armonikuser -u 5000 -G armonikuser --shell /bin/sh armonikuser && mkdir /cache && chown armonikuser: /cache
USER armonikuser

# Copy the application files, libraries, and binaries from the builder image to the final image
COPY --from=builder /app /app

# Update the PATH environment variable to include the application libraries and binaries
ENV LD_LIBRARY_PATH="/app/install/lib:$LD_LIBRARY_PATH"
ENV PATH="/app/install/bin:$PATH"

# Set the entrypoint for the application's test executable
# This is the command that will be executed when the container is run
ENTRYPOINT ["/app/install/bin/ArmoniK.Api.Worker.Tests"]
# Start with the latest Alpine base image for the build stage
FROM alpine AS builder
ARG GRPC_VERSION=v1.54.0

# Install all the necessary dependencies required for the build process
# These include tools and libraries for building and compiling the source code
RUN apk update && apk add --no-cache \
git \
gcc \
g++ \
build-base \
autoconf \
automake \
libtool \
curl \
c-ares \
c-ares-dev \
make \
cmake \
unzip \
linux-headers \
grpc \
grpc-dev \
protobuf \
protobuf-dev \
libfmt-dev

# Update the PATH environment variable to include the gRPC libraries and binaries
ENV LD_LIBRARY_PATH="/app/install/lib:$LD_LIBRARY_PATH"
ENV PATH="/app/install/bin:$PATH"

# Display the updated PATH environment variable
RUN echo $PATH

# Copy the application source files into the image
WORKDIR /app/source
COPY ./packages/cpp/ArmoniK.Api.Common ./ArmoniK.Api.Common
COPY ./packages/cpp/ArmoniK.Api.Worker ./ArmoniK.Api.Worker
COPY ./packages/cpp/ArmoniK.Api.Worker.Tests ./ArmoniK.Api.Worker.Tests
COPY ./packages/cpp/CMakeLists.txt ./

# Copy the Protocol Buffer definition files into the image
WORKDIR /app/proto
COPY ./Protos/V1/ /app/proto

# Build the application using the copied source files and protobuf definitions
WORKDIR /app/builder
RUN cmake -DCMAKE_INSTALL_PREFIX="/app/install" -DPROTO_FILES_DIR="/app/proto" -DBUILD_TEST=ON -DBUILD_CLIENT=OFF -DBUILD_WORKER=ON /app/source/
RUN make -j $(nproc) install

# Start with the latest Alpine base image for the final stage
FROM alpine
# Install all the necessary dependencies required for the build process
# These include tools and libraries for building and compiling the source code
RUN apk update && apk add --no-cache \
git \
gcc \
g++ \
build-base \
autoconf \
automake \
libtool \
curl \
c-ares \
c-ares-dev \
make \
cmake \
unzip \
linux-headers \
libprotobuf \
grpc \
grpc-cpp

# Create a non-root user and group for running the application
# This is a security best practice to avoid running applications as the root user
RUN addgroup -g 5000 -S armonikuser && adduser -D -h /home/armonikuser -u 5000 -G armonikuser --shell /bin/sh armonikuser && mkdir /cache && chown armonikuser: /cache
USER armonikuser

# Copy the application files, libraries, and binaries from the builder image to the final image
COPY --from=builder /app /app

# Update the PATH environment variable to include the application libraries and binaries
ENV LD_LIBRARY_PATH="/app/install/lib:$LD_LIBRARY_PATH"
ENV PATH="/app/install/bin:$PATH"

# Set the entrypoint for the application's test executable
# This is the command that will be executed when the container is run
ENTRYPOINT ["/app/install/bin/ArmoniK.Api.Worker.Tests"]

0 comments on commit 8815951

Please sign in to comment.