Skip to content

Commit

Permalink
Removed Glider and clean the compose [#54]
Browse files Browse the repository at this point in the history
  • Loading branch information
RicYaben committed Jul 10, 2022
1 parent edbe15a commit 7eac3af
Show file tree
Hide file tree
Showing 6 changed files with 241 additions and 77 deletions.
21 changes: 8 additions & 13 deletions build/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Start from the latest golang base image
FROM golang:1.18
FROM golang:1.18 as builder
LABEL maintainer="Shreyas Srinivasa <shsr@es.aau.dk>"

ENV GO111MODULE=on
Expand All @@ -16,14 +15,6 @@ COPY go.sum .
# download all the dependencies
RUN go mod download

# download and install glider
RUN wget https://github.com/nadoo/glider/releases/download/v0.15.0/glider_0.15.0_linux_amd64.tar.gz

RUN tar -xzf glider_0.15.0_linux_amd64.tar.gz && cd glider_0.15.0_linux_amd64 && cp glider /usr/bin/

# install netcat so we can ping the db until it is ready
RUN apt-get update && apt-get install -y netcat

# Copy everything into the image
# Copy only the app files in the image
COPY internal internal/
Expand All @@ -40,8 +31,12 @@ COPY build/docker/entrypoint.sh ./
COPY Makefile .
RUN make builder

# give permissions to the entrypoint to run the file
RUN chmod +x ./entrypoint.sh
FROM golang:1.18 as stage
WORKDIR /app

# TODO: Copy the plugins
COPY --from=stage cmd/riotpot/main.go ./
USER 1000

# Run RIoTPot
ENTRYPOINT [ "./entrypoint.sh" ]
ENTRYPOINT [ "./main.go" ]
57 changes: 57 additions & 0 deletions build/docker/docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
version: "3.8"

services:

# Tcpdump host that stores all the stuff that happens
# in the network
tcpdump:
image: kaazing/tcpdump
network_mode: "host"
volumes:
- ../tcpdump:/tcpdump
# Run tcdump in autorotating mode, with gzip compression
# The files will be rotated every 24h or 500MB and named
# after the timestamp when the file is created.
command: [
"-z", "gzip", # compress to gzip
"-G", "86400", # 24h in seconds
"-C", "500", # maximum file size
"-W", "10", # ignored, only affects the name
"-v", # verbose
"-i", "any", # any interface
"-w", "tcpdump/trace_%Y_%m_%d_%H_%M_%S.pcap" # trace_<timestamp>.pcap
]

# RIoTPot is the container for the central node
riotpot:
build:
context: ../..
dockerfile: ./build/docker/Dockerfile
image: riotpot:development
#command:
restart: always
ports:
# Ports under 60 might see errors when unquoted
# https://stackoverflow.com/questions/58810789/quotes-on-docker-compose-yml-ports-make-any-difference
- "7:7"
- "22:22"
- "23:23"
#- "80:80"
- "502:502"
- "8080:8080"
- "1883:1883"
- "5683:5683"
env_file:
- ../build/env/.env

postgres:
image: postgres:latest
environment:
- POSTGRES_USER=user
- POSTGRES_PASSWORD=password
- POSTGRES_DB=db
volumes:
- postgres_data:/var/lib/postgresql/data/

volumes:
postgres_data:
139 changes: 139 additions & 0 deletions build/docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# This Docker Compose file is meant to be used on a development environment for testing.
# This environment includes a fake local network, a local database and
# a volume mounted with the code to see changes on the go.

# Base configuration for any protocol container
# Use this on each protocol so share a similar configuration to riotpot
x-protocol:
&protocol
profiles:
- protocol
depends_on:
- riotpot
networks:
honeypot:

services:

##########################################
# REQUIRED
##########################################

# Tcpdump host that stores all the stuff that happens
# in the network
tcpdump:
image: kaazing/tcpdump
network_mode: "host"
volumes:
- ../tcpdump:/tcpdump
# Run tcdump in autorotating mode, with gzip compression
# The files will be rotated every 24h or 500MB and named
# after the timestamp when the file is created.
command: [
"-z", "gzip", # compress to gzip
"-G", "86400", # 24h in seconds
"-C", "500", # maximum file size
"-W", "10", # ignored, only affects the name
"-v", # verbose
"-i", "any", # any interface
"-w", "tcpdump/trace_%Y_%m_%d_%H_%M_%S.pcap" # trace_<timestamp>.pcap
]

database:
image: mongo
container_name: database
environment:
MONGO_INITDB_ROOT_USERNAME: ${DB_USER:-superuser}
MONGO_INITDB_ROOT_PASSWORD: ${DB_PASS:-password}
MONGO_INITDB_DATABASE: ${DB_NAME:-db}
ports:
- "27017:27017"
volumes:
- riotpot_db:/data/db/
networks:
honeypot:
# Probe the db service before letting other services know of its status
healthcheck:
test: ["CMD","mongo", "--eval", "db.adminCommand('ping')"]
interval: 10s
timeout: 10s
retries: 5
start_period: 20s

# RIoTPot application
riotpot:
container_name: riotpot
build:
context: ../..
dockerfile: ./build/docker/Dockerfile
restart: always # restart riotpot when it crashes
depends_on:
- database
links:
- database
ports:
# Ports under 60 might see errors when unquoted
# https://stackoverflow.com/questions/58810789/quotes-on-docker-compose-yml-ports-make-any-difference
- "7:7"
# - "22:22"
- "23:23"
# - "80:80"
- "502:502"
- "8080:8080"
- "1883:1883"
- "5683:5683"
- "27017:27017"
env_file:
- ../build/env/.env
networks:
honeypot:

##########################################
# PROTOCOLS
##########################################
# Use the profile `protocol` to mount the image but do not start it
# riotpot will deetermine which containers to start at a later time

mqtt:
image: eclipse-mosquitto
container_name: mqtt
<<: *protocol

http:
image: httpd
container_name: http
<<: *protocol

modbus:
image: oitc/modbus-server
container_name: modbus
<<: *protocol

ocpp:
image: ldonini/ocpp1.6-central-system # v1.6
container_name: ocpp
<<: *protocol


##########################################
# EXTRA
##########################################
# Profile: `extra`

# Attacker container.
# This container is meant to interact with the
attacker:
build:
context: ..
dockerfile: ./build/docker/Dockerfile.attacker
stdin_open: true # docker -i
tty: true # docker -t
volumes:
- ../test/pkg/services/mqtt:/riotpot/
networks:
honeypot:
profiles:
- extra

volumes:
riotpot_db:
18 changes: 0 additions & 18 deletions build/docker/entrypoint.sh

This file was deleted.

42 changes: 37 additions & 5 deletions build/env/.env
Original file line number Diff line number Diff line change
@@ -1,7 +1,39 @@
AUTOD=false
DB_HOST=mongodb
DB_USER=superuser
DB_PASS=password
# +------------------+
# Place here the environment variables values with which you
# want to run riotpot.
# This variables will replace the configuration used on runtime,
# and any previously stored configuration.
# +------------------+
# +------------------+

# Boolean-like. This variable defines if you rather allow the honeypot
# to load all the services available in both the configuration
# file and installed plugins.
AUTOD=true

# Fill only if AUTOD is set to a falsy value.
# Place a comma separated list of emulators that you want
# riotpot to start when initialised.
## NOTE: RIoTPot is *always* run in hybrid mode!
## append a `-c` to the name when using a containerised version
## Example: `http-c`
START=

# +------------------+ DB
# Here you can find the list of variables related to the database
# that will be used to store the data generated by riotpot
# +------------------+ DB

# Place here the name that will be used for the database
# By default, riotpot will call it `default`
DB_NAME=db

# Username and password used to log the information
DB_USER=user
DB_PASS=password

# Host and Port in where the database is located
DB_HOST=database
DB_PORT=27017
DB_ENGINE=mongodb

# +------------------+ DB
41 changes: 0 additions & 41 deletions build/env/.env.example

This file was deleted.

0 comments on commit 7eac3af

Please sign in to comment.