mirror of
https://github.com/aquasecurity/kube-hunter.git
synced 2026-02-14 09:59:55 +00:00
Fix Dockerfile build (#303)
* Fix Dockerfile build The Docker build used a 2-step installation of requirements and application. This was broken by #272. Fixes #300 * Add dependencies cache for docker build Caching installation requirements saves time when building
This commit is contained in:
committed by
GitHub
parent
ac5dd40b74
commit
11efbb7514
4
.dockerignore
Normal file
4
.dockerignore
Normal file
@@ -0,0 +1,4 @@
|
||||
*.png
|
||||
tests/
|
||||
docs/
|
||||
.github/
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,6 +1,5 @@
|
||||
*.pyc
|
||||
.venv
|
||||
.dockerignore
|
||||
*aqua*
|
||||
venv/
|
||||
.vscode
|
||||
|
||||
26
Dockerfile
26
Dockerfile
@@ -1,25 +1,19 @@
|
||||
FROM python:3.7-alpine3.10 as builder
|
||||
FROM python:3.8-alpine as builder
|
||||
|
||||
RUN apk add --no-cache \
|
||||
linux-headers \
|
||||
tcpdump \
|
||||
build-base \
|
||||
ebtables
|
||||
ebtables \
|
||||
make \
|
||||
git && \
|
||||
apk upgrade --no-cache
|
||||
|
||||
WORKDIR /kube-hunter
|
||||
COPY ./requirements.txt /kube-hunter/.
|
||||
RUN pip install -r /kube-hunter/requirements.txt -t /kube-hunter
|
||||
COPY setup.py setup.cfg Makefile ./
|
||||
RUN make deps
|
||||
|
||||
COPY . /kube-hunter
|
||||
COPY . .
|
||||
RUN make install
|
||||
|
||||
FROM python:3.7-alpine3.10
|
||||
|
||||
RUN apk add --no-cache \
|
||||
tcpdump
|
||||
RUN apk upgrade --no-cache
|
||||
|
||||
COPY --from=builder /kube-hunter /kube-hunter
|
||||
|
||||
WORKDIR /kube-hunter
|
||||
|
||||
ENTRYPOINT ["python", "kube-hunter.py"]
|
||||
ENTRYPOINT ["kube-hunter"]
|
||||
|
||||
9
Makefile
9
Makefile
@@ -1,4 +1,4 @@
|
||||
.SILENT:
|
||||
.SILENT: clean
|
||||
|
||||
NAME := kube-hunter
|
||||
SRC := kube_hunter
|
||||
@@ -10,6 +10,13 @@ STATIC_COMPILED := $(COMPILED).static
|
||||
|
||||
.PHONY: deps
|
||||
deps:
|
||||
requires=$(shell mktemp)
|
||||
python setup.py -q dependencies > \$requires
|
||||
pip install -r \$requires
|
||||
rm \$requires
|
||||
|
||||
.PHONY: dev-deps
|
||||
dev-deps:
|
||||
pip install -r requirements-dev.txt
|
||||
|
||||
.PHONY: lint
|
||||
|
||||
28
setup.py
28
setup.py
@@ -4,6 +4,25 @@ from configparser import ConfigParser
|
||||
from setuptools import setup, Command
|
||||
|
||||
|
||||
class ListDependenciesCommand(Command):
|
||||
"""A custom command to list dependencies"""
|
||||
|
||||
description = "list package dependencies"
|
||||
user_options = []
|
||||
|
||||
def initialize_options(self):
|
||||
pass
|
||||
|
||||
def finalize_options(self):
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
cfg = ConfigParser()
|
||||
cfg.read("setup.cfg")
|
||||
requirements = cfg["options"]["install_requires"]
|
||||
print(requirements)
|
||||
|
||||
|
||||
class PyInstallerCommand(Command):
|
||||
"""A custom command to run PyInstaller to build standalone executable."""
|
||||
|
||||
@@ -36,6 +55,11 @@ class PyInstallerCommand(Command):
|
||||
|
||||
|
||||
setup(
|
||||
use_scm_version=True,
|
||||
cmdclass={"pyinstaller": PyInstallerCommand},
|
||||
use_scm_version={
|
||||
"fallback_version": "noversion"
|
||||
},
|
||||
cmdclass={
|
||||
"dependencies": ListDependenciesCommand,
|
||||
"pyinstaller": PyInstallerCommand,
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user