Skip to content

Commit

Permalink
Fixing the Dockerfile (#522)
Browse files Browse the repository at this point in the history
* using debian for wheels and 10x faster build
  • Loading branch information
glaslos authored Nov 13, 2020
1 parent 83d0738 commit 68702a4
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 93 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ exclude_lines =
if 0:
if __name__ == .__main__.:

ignore_errors = True
ignore_errors = True
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.github
.vscode
.coveragerc
.gitignore
.landscape.yaml
.travis.yaml
Changelog.txt
docker-compose.xml
Dockerfile
LICENSE.txt
Makefile
14 changes: 14 additions & 0 deletions .github/workflows/xmllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: XML Lint

on: [push]

jobs:
xmllint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Run XMLLint
uses: ChristophWurst/xmllint-action@v1
with:
xml-file: ./conpot/templates/default/template.xml
xml-schema-file: ./conpot/tests/template_schemas/core.xsd
49 changes: 18 additions & 31 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,37 @@
language: python
python:
- '3.7'
- "3.7"
virtualenv:
system_site_packages: false
sudo: false
cache:
- apt
- pip
- apt
- pip
before_install:
- export TRAVIS_COMMIT_MSG="$(git log --format=%B --no-merges -n 1)"
- REPO=`pwd`
- echo $REPO
- echo $TRAVIS_TAG
- pwd
- export TRAVIS_COMMIT_MSG="$(git log --format=%B --no-merges -n 1)"
- REPO=`pwd`
- echo $REPO
- echo $TRAVIS_TAG
- pwd
services:
- mysql
addons:
apt:
packages:
- python3-pip
- git
- unzip
- python-dev
- libevent-dev
- libxml2
- libxml2-dev
- libxml2-utils
- python-mysqldb
- libmysqlclient-dev
- ipmitool
- ipmitool
install:
- export PYTHONIOENCODING=UTF8
- git show HEAD:conpot/__init__.py > docs/source/conpot_version.py
- pip install coveralls
- pip install tox
- pip install -r requirements.txt
- export PYTHONIOENCODING=UTF8
- git show HEAD:conpot/__init__.py > docs/source/conpot_version.py
- pip install coveralls
- pip install tox
- pip install -r requirements.txt
before_script:
- mysql -e 'CREATE DATABASE IF NOT EXISTS conpot_unittest;'
- chmod +x "$REPO/bin/conpot"
- mysql -e 'CREATE DATABASE IF NOT EXISTS conpot_unittest;'
- chmod +x "$REPO/bin/conpot"
script:
- tox
- xmllint --schema conpot/tests/template_schemas/core.xsd conpot/templates/default/template.xml
- tox
after_success:
- coveralls
- coveralls
notifications:
irc:
- irc.freenode.org#conpot-dev
slack:
secure: kNsZ0yGar7bcvU4xazqCeGf8zJ8PfbQ16X+Q4Fzu4mHNcnmmal80BHMwHKHfg5SBZViDVqZeA+yEGFAK4z93IXGKLhcCkXiw7qm9K29dP7DWgAFwDn42XNPjx5mQF9elr6T8AD0S1oQM4ML+0h1I+nYY+SK28UUjvDh65o9NHqA=
43 changes: 43 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM python:3.8 AS conpot-builder

RUN apt-get update && apt-get install -y \
libmariadb-dev \
gcc \
&& rm -rf /var/lib/apt/lists/*

# Copy the app from the host folder (probably a cloned repo) to the container
RUN adduser --disabled-password --gecos "" conpot

COPY --chown=conpot:conpot . /opt/conpot/

# Install Conpot
USER conpot
ENV PATH=$PATH:/home/conpot/.local/bin
RUN pip3 install --user --no-cache-dir /opt/conpot


# Run container
FROM python:3.8-slim

RUN apt-get update && apt-get install -y \
wget \
&& rm -rf /var/lib/apt/lists/*

RUN adduser --disabled-password --gecos "" conpot
WORKDIR /home/conpot

COPY --from=conpot-builder --chown=conpot:conpot /home/conpot/.local/ /home/conpot/.local/
RUN mkdir -p /etc/conpot /var/log/conpot /usr/share/wireshark \
&& wget https://github.com/wireshark/wireshark/raw/master/manuf -o /usr/share/wireshark/manuf

# Create directories
RUN mkdir -p /var/log/conpot/ \
&& mkdir -p /data/tftp/ \
&& chown conpot:conpot /var/log/conpot \
&& chown conpot:conpot -R /data

USER conpot
WORKDIR /home/conpot
ENV USER=conpot
ENTRYPOINT ["/home/conpot/.local/bin/conpot"]
CMD ["--template", "default", "--logfile", "/var/log/conpot/conpot.log", "-f", "--temp_dir", "/tmp" ]
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: docker
build-docker:
docker build -t conpot docker/
docker build -t conpot:latest .

run-docker: build-docker
docker run -it -p 80:8800 -p 102:10201 -p 502:5020 -p 161:16100/udp -p 47808:47808/udp -p 623:6230/udp -p 21:2121 -p 69:6969/udp -p 44818:44818 --network=bridge conpot
docker run -it -p 80:8800 -p 102:10201 -p 502:5020 -p 161:16100/udp -p 47808:47808/udp -p 623:6230/udp -p 21:2121 -p 69:6969/udp -p 44818:44818 --network=bridge conpot:latest
File renamed without changes.
56 changes: 0 additions & 56 deletions docker/Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion docs/source/installation/quick_install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Build from source and run with docker-compose
1. Install `docker-compose`_
2. Clone this repo with
``git clone https://github.com/mushorg/conpot.git`` and
``cd conpot/docker``
``cd conpot``
3. Build the image with ``docker-compose build``
4. Test if everything is running correctly with ``docker-compose up``
5. Permanently run as a daemon with ``docker-compose up -d``
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ hpfeeds3
modbus-tk
stix-validator
stix
pycrypto
cybox
bacpypes==0.17.0
pyghmi==1.4.1
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ envdir = {toxinidir}/.tox/py37
basepython = python3.7
commands =
{envpython} setup.py install
{posargs:conpot -f}
{posargs:conpot -f}

0 comments on commit 68702a4

Please sign in to comment.