Commit fc3e9180 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Optical Cybersecurity components:

- Corrected Dockerfiles
parent c3c6e181
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -31,9 +31,8 @@ RUN GRPC_HEALTH_PROBE_VERSION=v0.2.0 && \
RUN groupadd -r teraflow && useradd -u 1001 --no-log-init -r -m -g teraflow teraflow
USER teraflow

RUN mkdir -p /home/teraflow/controller/common

# set working directory
RUN mkdir -p /home/teraflow/controller/common
WORKDIR /home/teraflow/controller

# Get Python packages per module
@@ -58,7 +57,9 @@ COPY --chown=teraflow:teraflow src/common/. ./
RUN rm -rf proto

# Create proto sub-folder, copy .proto files, and generate Python code
RUN mkdir -p /home/teraflow/controller/common/proto
WORKDIR /home/teraflow/controller/common/proto
RUN touch __init__.py
COPY --chown=teraflow:teraflow proto/*.proto ./
RUN python3 -m grpc_tools.protoc -I=. --python_out=. --grpc_python_out=. *.proto
RUN rm *.proto
@@ -77,5 +78,5 @@ RUN python3 -m pip install -r dbscanserving/requirements.txt
# Add component files into working directory
COPY --chown=teraflow:teraflow ./src/dbscanserving/. dbscanserving

# Start dbscanserving service
# Start the service
ENTRYPOINT ["python", "-m", "dbscanserving.service"]
+11 −9
Original line number Diff line number Diff line
@@ -55,8 +55,10 @@ RUN python3 -m pip install -r common_requirements.txt
# Add common files into working directory
WORKDIR /home/teraflow/controller/common
COPY --chown=teraflow:teraflow src/common/. ./
RUN rm -rf proto

# Create proto sub-folder, copy .proto files, and generate Python code
RUN mkdir -p /home/teraflow/controller/common/proto
WORKDIR /home/teraflow/controller/common/proto
RUN touch __init__.py
COPY --chown=teraflow:teraflow proto/*.proto ./
@@ -69,18 +71,18 @@ RUN mkdir -p /home/teraflow/controller/opticalattackdetector
WORKDIR /home/teraflow/controller

# Get Python packages per module
COPY --chown=teraflow:teraflow src/opticalattackdetector/requirements.in opticalattackdetector/requirements.in
COPY --chown=teraflow:teraflow ./src/opticalattackdetector/requirements.in opticalattackdetector/requirements.in
# consider common and specific requirements to avoid inconsistencies with dependencies
RUN pip-compile --quiet --output-file=opticalattackdetector/requirements.txt opticalattackdetector/requirements.in common_requirements.in
RUN python3 -m pip install -r opticalattackdetector/requirements.txt

# Add files into working directory
COPY --chown=teraflow:teraflow src/context/. context
COPY --chown=teraflow:teraflow src/service/. service
COPY --chown=teraflow:teraflow src/monitoring/. monitoring
COPY --chown=teraflow:teraflow src/dbscanserving/. dbscanserving
COPY --chown=teraflow:teraflow src/opticalattackmitigator/. opticalattackmitigator
COPY --chown=teraflow:teraflow src/opticalattackdetector/. opticalattackdetector
# Add component files into working directory
COPY --chown=teraflow:teraflow ./src/context/. context
COPY --chown=teraflow:teraflow ./src/service/. service
COPY --chown=teraflow:teraflow ./src/monitoring/. monitoring
COPY --chown=teraflow:teraflow ./src/dbscanserving/. dbscanserving
COPY --chown=teraflow:teraflow ./src/opticalattackmitigator/. opticalattackmitigator
COPY --chown=teraflow:teraflow ./src/opticalattackdetector/. opticalattackdetector

# Start opticalattackdetector service
# Start the service
ENTRYPOINT ["python", "-m", "opticalattackdetector.service"]
+12 −13
Original line number Diff line number Diff line
@@ -16,11 +16,9 @@ FROM python:3.9-slim

# Install dependencies
RUN apt-get --yes --quiet --quiet update && \
    apt-get --yes --quiet --quiet install wget g++ nano && \
    apt-get --yes --quiet --quiet install wget g++ && \
    rm -rf /var/lib/apt/lists/*

# TODO: remove nano from installation

# Set Python to show logs as they occur
ENV PYTHONUNBUFFERED=0
ENV PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
@@ -53,7 +51,7 @@ RUN python3 -m pip install --upgrade pip-tools
COPY --chown=teraflow:teraflow common_requirements.in common_requirements.in
COPY --chown=teraflow:teraflow src/opticalattackmanager/requirements.in opticalattackmanager/requirements.in
RUN sed -i '/protobuf/d' common_requirements.in && sed -i '/grpc/d' common_requirements.in
RUN pip-compile --output-file=common_requirements.txt common_requirements.in opticalattackmanager/requirements.in
RUN pip-compile --quiet --output-file=common_requirements.txt common_requirements.in opticalattackmanager/requirements.in
RUN python3 -m pip install -r common_requirements.txt

# Get Python packages per module
@@ -64,11 +62,12 @@ RUN python3 -m pip install -r common_requirements.txt
# Add common files into working directory
WORKDIR /home/teraflow/controller/common
COPY --chown=teraflow:teraflow src/common/. ./
RUN rm -rf proto

# Create proto sub-folder, copy .proto files, and generate Python code
RUN mkdir -p /home/teraflow/controller/common/proto/asyncio
WORKDIR /home/teraflow/controller/common/proto
RUN touch __init__.py
RUN mkdir -p /home/teraflow/controller/common/proto/asyncio
RUN touch asyncio/__init__.py
COPY --chown=teraflow:teraflow proto/*.proto ./
RUN python3 -m grpc_tools.protoc -I=. --python_out=. --grpc_python_out=. *.proto
@@ -81,13 +80,13 @@ RUN find . -type f -exec sed -i -E 's/(import\ .*)_pb2/from . \1_pb2/g' {} \;
RUN mkdir -p /home/teraflow/controller/opticalattackmanager
WORKDIR /home/teraflow/controller

# Add files into working directory
COPY --chown=teraflow:teraflow src/context/. context
COPY --chown=teraflow:teraflow src/monitoring/. monitoring
COPY --chown=teraflow:teraflow src/dbscanserving/. dbscanserving
COPY --chown=teraflow:teraflow src/opticalattackdetector/. opticalattackdetector
COPY --chown=teraflow:teraflow src/opticalattackmitigator/. opticalattackmitigator
COPY --chown=teraflow:teraflow src/opticalattackmanager/. opticalattackmanager
# Add component files into working directory
COPY --chown=teraflow:teraflow ./src/context/. context
COPY --chown=teraflow:teraflow ./src/monitoring/. monitoring
COPY --chown=teraflow:teraflow ./src/dbscanserving/. dbscanserving
COPY --chown=teraflow:teraflow ./src/opticalattackdetector/. opticalattackdetector
COPY --chown=teraflow:teraflow ./src/opticalattackmitigator/. opticalattackmitigator
COPY --chown=teraflow:teraflow ./src/opticalattackmanager/. opticalattackmanager

# Start opticalattackmanager service
# Start the service
ENTRYPOINT ["python", "-m", "opticalattackmanager.service"]
+6 −4
Original line number Diff line number Diff line
@@ -54,8 +54,10 @@ RUN python3 -m pip install -r common_requirements.txt
# Add common files into working directory
WORKDIR /home/teraflow/controller/common
COPY --chown=teraflow:teraflow src/common/. ./
RUN rm -rf proto

# Create proto sub-folder, copy .proto files, and generate Python code
RUN mkdir -p /home/teraflow/controller/common/proto
WORKDIR /home/teraflow/controller/common/proto
RUN touch __init__.py
COPY --chown=teraflow:teraflow proto/*.proto ./
@@ -68,13 +70,13 @@ RUN mkdir -p /home/teraflow/controller/opticalattackmitigator
WORKDIR /home/teraflow/controller

# Get Python packages per module
COPY --chown=teraflow:teraflow src/opticalattackmitigator/requirements.in opticalattackmitigator/requirements.in
COPY --chown=teraflow:teraflow ./src/opticalattackmitigator/requirements.in opticalattackmitigator/requirements.in
# consider common and specific requirements to avoid inconsistencies with dependencies
RUN pip-compile --quiet --output-file=opticalattackmitigator/requirements.txt opticalattackmitigator/requirements.in common_requirements.in
RUN python3 -m pip install -r opticalattackmitigator/requirements.txt

# Add files into working directory
COPY --chown=teraflow:teraflow src/opticalattackmitigator/. opticalattackmitigator
# Add component files into working directory
COPY --chown=teraflow:teraflow ./src/opticalattackmitigator/. opticalattackmitigator

# Start opticalattackmitigator service
# Start the service
ENTRYPOINT ["python", "-m", "opticalattackmitigator.service"]