|
| 1 | +FROM nginx:stable |
| 2 | + |
| 3 | +# Update repo and install some utilities and prerequisites |
| 4 | +RUN apt-get update -y |
| 5 | +RUN apt-get -y install git vim wget curl at gnupg procps |
| 6 | +RUN apt-get -y install ca-certificates jq openssl task-spooler apt-transport-https python3 python3-pip redis libssl-dev |
| 7 | +RUN apt-get -y install python3-yaml python3-kubernetes python3-redis python3-requests |
| 8 | + |
| 9 | +# Install kubectl |
| 10 | +RUN curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" |
| 11 | +RUN chmod +x ./kubectl |
| 12 | +RUN mv ./kubectl /usr/local/bin/kubectl |
| 13 | + |
| 14 | +# Install Openresty |
| 15 | +RUN wget -O - https://openresty.org/package/pubkey.gpg | apt-key add - |
| 16 | +RUN codename=`grep -Po 'VERSION="[0-9]+ \(\K[^)]+' /etc/os-release` && echo "deb http://openresty.org/package/debian $codename openresty" | tee /etc/apt/sources.list.d/openresty.list |
| 17 | +RUN apt-get update -y |
| 18 | +RUN apt-get -y install openresty |
| 19 | +RUN chmod 777 /usr/local/openresty/nginx |
| 20 | + |
| 21 | +# Install LUA Module |
| 22 | +RUN apt-get -y install luarocks lua-json lua-socket libyaml-dev |
| 23 | +RUN apt-get update --fix-missing |
| 24 | +RUN luarocks install luasec |
| 25 | +RUN luarocks install lunajson |
| 26 | +RUN luarocks install lyaml |
| 27 | + |
| 28 | +# Install kube-linter |
| 29 | +RUN curl -L -O https://github.com/stackrox/kube-linter/releases/download/0.6.0/kube-linter-linux.tar.gz |
| 30 | +RUN tar -xvf kube-linter-linux.tar.gz && rm -f kube-linter-linux.tar.gz |
| 31 | +RUN cp kube-linter /usr/local/bin/ && chmod 775 /usr/local/bin/kube-linter |
| 32 | +RUN mkdir /tmp/kube-linter-pods && chmod 777 /tmp/kube-linter-pods |
| 33 | + |
| 34 | +# Installl parser script for kubelinter |
| 35 | +COPY kube-linter/kube-linter-parser.sh /opt/kube-linter-parser.sh |
| 36 | +RUN chmod +x /opt/kube-linter-parser.sh |
| 37 | + |
| 38 | +# Install KubeInvaders (html and js) |
| 39 | +COPY html5/ /var/www/html |
| 40 | + |
| 41 | +# Configure Redis |
| 42 | +COPY confs/redis/redis.conf /etc/redis/redis.conf |
| 43 | + |
| 44 | +# Configure Nginx and KubeInvaders conf |
| 45 | +RUN sed -i.bak 's/listen\(.*\)80;/listen 8081;/' /etc/nginx/conf.d/default.conf |
| 46 | +RUN mkdir -p /usr/local/openresty/nginx/conf/kubeinvaders/data |
| 47 | +COPY nginx/nginx.conf /etc/nginx/nginx.conf |
| 48 | +COPY nginx/KubeInvaders.conf /etc/nginx/conf.d/KubeInvaders.conf |
| 49 | +RUN chmod g+rwx /var/cache/nginx /var/run /var/log/nginx /etc/nginx/conf.d |
| 50 | +RUN chmod 777 /var/www/html |
| 51 | + |
| 52 | +# Copy LUA scripts |
| 53 | +COPY scripts/metrics.lua /usr/local/openresty/nginx/conf/kubeinvaders/metrics.lua |
| 54 | +COPY scripts/pod.lua /usr/local/openresty/nginx/conf/kubeinvaders/pod.lua |
| 55 | +COPY scripts/ingress.lua /usr/local/openresty/nginx/conf/kubeinvaders/ingress.lua |
| 56 | +COPY scripts/node.lua /usr/local/openresty/nginx/conf/kubeinvaders/node.lua |
| 57 | +COPY scripts/kube-linter.lua /usr/local/openresty/nginx/conf/kubeinvaders/kube-linter.lua |
| 58 | +COPY scripts/chaos-node.lua /usr/local/openresty/nginx/conf/kubeinvaders/chaos-node.lua |
| 59 | +COPY scripts/chaos-containers.lua /usr/local/openresty/nginx/conf/kubeinvaders/chaos-containers.lua |
| 60 | +COPY scripts/programming_mode.lua /usr/local/openresty/nginx/conf/kubeinvaders/programming_mode.lua |
| 61 | +COPY scripts/config_kubeinv.lua /usr/local/openresty/lualib/config_kubeinv.lua |
| 62 | +COPY scripts/data/codenames.txt /usr/local/openresty/nginx/conf/kubeinvaders/data/codenames.txt |
| 63 | + |
| 64 | +# Copy Python helpers |
| 65 | +COPY scripts/programming_mode /opt/programming_mode/ |
| 66 | +COPY scripts/metrics_loop /opt/metrics_loop/ |
| 67 | +COPY scripts/logs_loop /opt/logs_loop/ |
| 68 | + |
| 69 | +EXPOSE 8080 |
| 70 | + |
| 71 | +ENV PATH=/usr/local/openresty/nginx/sbin:$PATH |
| 72 | + |
| 73 | +COPY ./entrypoint.sh / |
| 74 | + |
| 75 | +RUN chmod a+rwx ./entrypoint.sh |
| 76 | + |
| 77 | +ENTRYPOINT ["/entrypoint.sh"] |
0 commit comments