Skip to content
Snippets Groups Projects
Commit fc3e9180 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Optical Cybersecurity components:

- Corrected Dockerfiles
parent c3c6e181
No related branches found
No related tags found
1 merge request!142Release TeraFlowSDN 2.1
...@@ -31,9 +31,8 @@ RUN GRPC_HEALTH_PROBE_VERSION=v0.2.0 && \ ...@@ -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 RUN groupadd -r teraflow && useradd -u 1001 --no-log-init -r -m -g teraflow teraflow
USER teraflow USER teraflow
RUN mkdir -p /home/teraflow/controller/common
# set working directory # set working directory
RUN mkdir -p /home/teraflow/controller/common
WORKDIR /home/teraflow/controller WORKDIR /home/teraflow/controller
# Get Python packages per module # Get Python packages per module
...@@ -58,7 +57,9 @@ COPY --chown=teraflow:teraflow src/common/. ./ ...@@ -58,7 +57,9 @@ COPY --chown=teraflow:teraflow src/common/. ./
RUN rm -rf proto RUN rm -rf proto
# Create proto sub-folder, copy .proto files, and generate Python code # 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 WORKDIR /home/teraflow/controller/common/proto
RUN touch __init__.py
COPY --chown=teraflow:teraflow proto/*.proto ./ COPY --chown=teraflow:teraflow proto/*.proto ./
RUN python3 -m grpc_tools.protoc -I=. --python_out=. --grpc_python_out=. *.proto RUN python3 -m grpc_tools.protoc -I=. --python_out=. --grpc_python_out=. *.proto
RUN rm *.proto RUN rm *.proto
...@@ -77,5 +78,5 @@ RUN python3 -m pip install -r dbscanserving/requirements.txt ...@@ -77,5 +78,5 @@ RUN python3 -m pip install -r dbscanserving/requirements.txt
# Add component files into working directory # Add component files into working directory
COPY --chown=teraflow:teraflow ./src/dbscanserving/. dbscanserving COPY --chown=teraflow:teraflow ./src/dbscanserving/. dbscanserving
# Start dbscanserving service # Start the service
ENTRYPOINT ["python", "-m", "dbscanserving.service"] ENTRYPOINT ["python", "-m", "dbscanserving.service"]
...@@ -55,8 +55,10 @@ RUN python3 -m pip install -r common_requirements.txt ...@@ -55,8 +55,10 @@ RUN python3 -m pip install -r common_requirements.txt
# Add common files into working directory # Add common files into working directory
WORKDIR /home/teraflow/controller/common WORKDIR /home/teraflow/controller/common
COPY --chown=teraflow:teraflow src/common/. ./ COPY --chown=teraflow:teraflow src/common/. ./
RUN rm -rf proto
# Create proto sub-folder, copy .proto files, and generate Python code # 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 WORKDIR /home/teraflow/controller/common/proto
RUN touch __init__.py RUN touch __init__.py
COPY --chown=teraflow:teraflow proto/*.proto ./ COPY --chown=teraflow:teraflow proto/*.proto ./
...@@ -69,18 +71,18 @@ RUN mkdir -p /home/teraflow/controller/opticalattackdetector ...@@ -69,18 +71,18 @@ RUN mkdir -p /home/teraflow/controller/opticalattackdetector
WORKDIR /home/teraflow/controller WORKDIR /home/teraflow/controller
# Get Python packages per module # 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 # 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 pip-compile --quiet --output-file=opticalattackdetector/requirements.txt opticalattackdetector/requirements.in common_requirements.in
RUN python3 -m pip install -r opticalattackdetector/requirements.txt RUN python3 -m pip install -r opticalattackdetector/requirements.txt
# Add files into working directory # Add component files into working directory
COPY --chown=teraflow:teraflow src/context/. context COPY --chown=teraflow:teraflow ./src/context/. context
COPY --chown=teraflow:teraflow src/service/. service COPY --chown=teraflow:teraflow ./src/service/. service
COPY --chown=teraflow:teraflow src/monitoring/. monitoring COPY --chown=teraflow:teraflow ./src/monitoring/. monitoring
COPY --chown=teraflow:teraflow src/dbscanserving/. dbscanserving COPY --chown=teraflow:teraflow ./src/dbscanserving/. dbscanserving
COPY --chown=teraflow:teraflow src/opticalattackmitigator/. opticalattackmitigator COPY --chown=teraflow:teraflow ./src/opticalattackmitigator/. opticalattackmitigator
COPY --chown=teraflow:teraflow src/opticalattackdetector/. opticalattackdetector COPY --chown=teraflow:teraflow ./src/opticalattackdetector/. opticalattackdetector
# Start opticalattackdetector service # Start the service
ENTRYPOINT ["python", "-m", "opticalattackdetector.service"] ENTRYPOINT ["python", "-m", "opticalattackdetector.service"]
...@@ -16,11 +16,9 @@ FROM python:3.9-slim ...@@ -16,11 +16,9 @@ FROM python:3.9-slim
# Install dependencies # Install dependencies
RUN apt-get --yes --quiet --quiet update && \ 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/* rm -rf /var/lib/apt/lists/*
# TODO: remove nano from installation
# Set Python to show logs as they occur # Set Python to show logs as they occur
ENV PYTHONUNBUFFERED=0 ENV PYTHONUNBUFFERED=0
ENV PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python ENV PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
...@@ -53,7 +51,7 @@ RUN python3 -m pip install --upgrade pip-tools ...@@ -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 common_requirements.in common_requirements.in
COPY --chown=teraflow:teraflow src/opticalattackmanager/requirements.in opticalattackmanager/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 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 RUN python3 -m pip install -r common_requirements.txt
# Get Python packages per module # Get Python packages per module
...@@ -64,11 +62,12 @@ RUN python3 -m pip install -r common_requirements.txt ...@@ -64,11 +62,12 @@ RUN python3 -m pip install -r common_requirements.txt
# Add common files into working directory # Add common files into working directory
WORKDIR /home/teraflow/controller/common WORKDIR /home/teraflow/controller/common
COPY --chown=teraflow:teraflow src/common/. ./ COPY --chown=teraflow:teraflow src/common/. ./
RUN rm -rf proto
# Create proto sub-folder, copy .proto files, and generate Python code # 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 WORKDIR /home/teraflow/controller/common/proto
RUN touch __init__.py RUN touch __init__.py
RUN mkdir -p /home/teraflow/controller/common/proto/asyncio
RUN touch asyncio/__init__.py RUN touch asyncio/__init__.py
COPY --chown=teraflow:teraflow proto/*.proto ./ COPY --chown=teraflow:teraflow proto/*.proto ./
RUN python3 -m grpc_tools.protoc -I=. --python_out=. --grpc_python_out=. *.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' {} \; ...@@ -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 RUN mkdir -p /home/teraflow/controller/opticalattackmanager
WORKDIR /home/teraflow/controller WORKDIR /home/teraflow/controller
# Add files into working directory # Add component files into working directory
COPY --chown=teraflow:teraflow src/context/. context COPY --chown=teraflow:teraflow ./src/context/. context
COPY --chown=teraflow:teraflow src/monitoring/. monitoring COPY --chown=teraflow:teraflow ./src/monitoring/. monitoring
COPY --chown=teraflow:teraflow src/dbscanserving/. dbscanserving COPY --chown=teraflow:teraflow ./src/dbscanserving/. dbscanserving
COPY --chown=teraflow:teraflow src/opticalattackdetector/. opticalattackdetector COPY --chown=teraflow:teraflow ./src/opticalattackdetector/. opticalattackdetector
COPY --chown=teraflow:teraflow src/opticalattackmitigator/. opticalattackmitigator COPY --chown=teraflow:teraflow ./src/opticalattackmitigator/. opticalattackmitigator
COPY --chown=teraflow:teraflow src/opticalattackmanager/. opticalattackmanager COPY --chown=teraflow:teraflow ./src/opticalattackmanager/. opticalattackmanager
# Start opticalattackmanager service # Start the service
ENTRYPOINT ["python", "-m", "opticalattackmanager.service"] ENTRYPOINT ["python", "-m", "opticalattackmanager.service"]
...@@ -54,8 +54,10 @@ RUN python3 -m pip install -r common_requirements.txt ...@@ -54,8 +54,10 @@ RUN python3 -m pip install -r common_requirements.txt
# Add common files into working directory # Add common files into working directory
WORKDIR /home/teraflow/controller/common WORKDIR /home/teraflow/controller/common
COPY --chown=teraflow:teraflow src/common/. ./ COPY --chown=teraflow:teraflow src/common/. ./
RUN rm -rf proto
# Create proto sub-folder, copy .proto files, and generate Python code # 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 WORKDIR /home/teraflow/controller/common/proto
RUN touch __init__.py RUN touch __init__.py
COPY --chown=teraflow:teraflow proto/*.proto ./ COPY --chown=teraflow:teraflow proto/*.proto ./
...@@ -68,13 +70,13 @@ RUN mkdir -p /home/teraflow/controller/opticalattackmitigator ...@@ -68,13 +70,13 @@ RUN mkdir -p /home/teraflow/controller/opticalattackmitigator
WORKDIR /home/teraflow/controller WORKDIR /home/teraflow/controller
# Get Python packages per module # 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 # 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 pip-compile --quiet --output-file=opticalattackmitigator/requirements.txt opticalattackmitigator/requirements.in common_requirements.in
RUN python3 -m pip install -r opticalattackmitigator/requirements.txt RUN python3 -m pip install -r opticalattackmitigator/requirements.txt
# Add files into working directory # Add component files into working directory
COPY --chown=teraflow:teraflow src/opticalattackmitigator/. opticalattackmitigator COPY --chown=teraflow:teraflow ./src/opticalattackmitigator/. opticalattackmitigator
# Start opticalattackmitigator service # Start the service
ENTRYPOINT ["python", "-m", "opticalattackmitigator.service"] ENTRYPOINT ["python", "-m", "opticalattackmitigator.service"]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment