diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..34a5a4f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +.git +.github +.cache +.run +cmake* +build +docker +docs +media +*.md \ No newline at end of file diff --git a/docker/client/Dockerfile b/docker/client/Dockerfile new file mode 100644 index 0000000..d5465b1 --- /dev/null +++ b/docker/client/Dockerfile @@ -0,0 +1,19 @@ +FROM build AS build + +# Build the client executable +RUN cd build && \ + make -j$(nproc) rabbitClientL3cmd + +# Runtime stage +FROM ubuntu:latest + +# Install necessary packages +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + libboost-all-dev + +# Copy the built executable from the build stage +COPY --from=build /usr/src/rabbit/build/rabbitClientL3cmd /usr/local/bin/ + +# Run the client +CMD ["rabbitClientL3cmd", "-i", "2", "-h", "server", "-p", "3030"] \ No newline at end of file diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..382b972 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,23 @@ +version: "3.8" + +services: + server: + build: + context: .. + dockerfile: ./docker/server/Dockerfile + ports: + - "3030:3030" + + client: + build: + context: .. + dockerfile: ./docker/client/Dockerfile + depends_on: + - server + + worker: + build: + context: .. + dockerfile: ./docker/worker/Dockerfile + depends_on: + - server \ No newline at end of file diff --git a/docker/server/Dockerfile b/docker/server/Dockerfile new file mode 100644 index 0000000..5d3967b --- /dev/null +++ b/docker/server/Dockerfile @@ -0,0 +1,53 @@ +FROM ubuntu:latest AS build + +# Install necessary packages +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + build-essential \ + cmake \ + python3 \ + python3-pip \ + python3-venv \ + git \ + unzip \ + tree + +# Create and activate a virtual environment +RUN python3 -m venv /opt/venv +ENV PATH="/opt/venv/bin:$PATH" + +# Upgrade pip and install conan in the virtual environment +RUN pip install --upgrade pip +RUN pip install conan +RUN conan profile detect --force + +WORKDIR /usr/src/rabbit + +# Download source code +COPY . . + +# RUN tree -L 4 + +# Install dependencies and build the project +RUN conan install . --output-folder=build --build=missing + +RUN cd build && cmake .. + +RUN cmake -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES="conan_provider.cmake" -B build . + +# Runtime stage +FROM ubuntu:latest + +# Install necessary packages +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + libboost-all-dev + +# Copy the built executable from the build stage +COPY --from=build /usr/src/rabbit/build/rabbitServerL3cmd /usr/local/bin/ + +# Expose the server port +EXPOSE 3030 + +# Run the server +CMD ["rabbitServerL3cmd", "-p", "3030"] diff --git a/docker/worker/Dockerfile b/docker/worker/Dockerfile new file mode 100644 index 0000000..507a78b --- /dev/null +++ b/docker/worker/Dockerfile @@ -0,0 +1,19 @@ +FROM build AS build + +# Build the worker executable +RUN cd build && \ + make -j$(nproc) rabbitWorkerL3cmd + +# Runtime stage +FROM ubuntu:latest + +# Install necessary packages +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + libboost-all-dev + +# Copy the built executable from the build stage +COPY --from=build /usr/src/rabbit/build/rabbitWorkerL3cmd /usr/local/bin/ + +# Run the worker +CMD ["rabbitWorkerL3cmd", "-i", "123", "-h", "server", "-p", "3030", "-c", "1000"] \ No newline at end of file