From 036aeb05d3cbafe0f21ca2ddaf34711eb7c5bc1a Mon Sep 17 00:00:00 2001
From: "claudiu.milea" <claudiu.milea@stud.acs.upb.ro>
Date: Thu, 2 Jun 2022 11:29:24 -0700
Subject: [PATCH] Update setup to include ethernet container; Add
 docker-compose with local docker images for the moment

---
 Dockerfile         | 16 ----------------
 Makefile           |  1 +
 can.Dockerfile     | 13 +++++++++++++
 docker-compose.yml | 14 ++++++++++++++
 eth.Dockerfile     | 12 ++++++++++++
 5 files changed, 40 insertions(+), 16 deletions(-)
 delete mode 100644 Dockerfile
 create mode 100644 can.Dockerfile
 create mode 100644 docker-compose.yml
 create mode 100644 eth.Dockerfile

diff --git a/Dockerfile b/Dockerfile
deleted file mode 100644
index 4515269..0000000
--- a/Dockerfile
+++ /dev/null
@@ -1,16 +0,0 @@
-#   The host exposes the virtual interface vcan0:
-#   https://stackoverflow.com/questions/21022749/how-to-create-virtual-can-port-on-linux-c
-#   sudo modprobe vcan
-#   sudo ip link add dev vcan0 type vcan
-#   sudo ip link set up vcan0
-
-FROM ubuntu:20.04
-
-RUN apt-get update -y
-RUN apt-get install can-utils
-
-# For the moment, expose the host network to the container for vcan0 visibility
-# https://www.lagerdata.com/articles/forwarding-can-bus-traffic-to-a-docker-container-using-vxcan-on-raspberry-pi
-CMD cangen vcan0
-
-# On the host system, run 'candump vlan0' command to capture generated CAN traffic
diff --git a/Makefile b/Makefile
index 84a4739..ecbc7ac 100644
--- a/Makefile
+++ b/Makefile
@@ -2,6 +2,7 @@ registry=gitlab.cs.pub.ro:5050/reaact/can-container
 img_name=can-container
 tag_name=${registry}
 
+# TODO: Update makefile
 build:
 	docker image build -t ${tag_name} .
 
diff --git a/can.Dockerfile b/can.Dockerfile
new file mode 100644
index 0000000..4586558
--- /dev/null
+++ b/can.Dockerfile
@@ -0,0 +1,13 @@
+# The host exposes the virtual interface vcan0:
+# https://stackoverflow.com/questions/21022749/how-to-create-virtual-can-port-on-linux-c
+#   sudo modprobe vcan
+#   sudo ip link add dev vcan0 type vcan
+#   sudo ip link set up vcan0
+
+FROM ubuntu:20.04
+
+RUN apt-get update -y
+RUN apt-get install can-utils
+
+# Keep the container running
+CMD tail -f /dev/null
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..78f3def
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,14 @@
+version: "3.3"
+services:
+  eth:
+    build:
+      context: .
+      dockerfile: ./eth.Dockerfile
+    network_mode: "host"
+    privileged: true
+  can:
+    build:
+      context: .
+      dockerfile: ./can.Dockerfile
+    network_mode: "host"
+    privileged: true
diff --git a/eth.Dockerfile b/eth.Dockerfile
new file mode 100644
index 0000000..2c18e37
--- /dev/null
+++ b/eth.Dockerfile
@@ -0,0 +1,12 @@
+FROM ubuntu:20.04
+
+RUN apt-get update
+RUN DEBIAN_FRONTEND=noninteractive TZ=Europe/Bucharest apt-get -y install tzdata
+RUN apt-get -y install iproute2
+RUN apt-get -y install netsniff-ng
+
+# Dummy trafgen config
+RUN echo "{ fill(0xff, 64) csum16(0, 64) }" > trafgen.cfg
+
+# Keep the container running
+CMD tail -f /dev/null
-- 
GitLab