Optimized Dockerfile for layer cache and moved all the installations for cache not to rerun the same layer for every code change for Docker container.

This commit is contained in:
JinnaBalu 2023-09-01 12:32:42 +05:30
parent f5aff5547a
commit 1c2cbbbe2a
3 changed files with 37 additions and 24 deletions

View File

@ -1,21 +1,12 @@
FROM kalilinux/kali-rolling FROM kalilinux/kali-rolling:latest
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y git python3-pip figlet sudo; apt-get install -y git python3-pip figlet sudo && \
apt-get install -y boxes php curl xdotool wget
#Install packages dependencies
RUN true && \
apt-get install -y boxes php curl xdotool wget;
WORKDIR /root/hackingtool WORKDIR /root/hackingtool
COPY requirements.txt ./
RUN pip3 install --no-cache-dir boxes flask lolcat requests -r requirements.txt
COPY . . COPY . .
RUN true && echo "/root/hackingtool/" > /home/hackingtoolpath.txt;
RUN true && \
pip3 install boxes flask lolcat requests -r requirements.txt;
RUN true && \
echo "/root/hackingtool/" > /home/hackingtoolpath.txt;
EXPOSE 1-65535 EXPOSE 1-65535
ENTRYPOINT ["python3", "/root/hackingtool/hackingtool.py"]
ENTRYPOINT ["python3", "/root/hackingtool/hackingtool.py"]

View File

@ -240,13 +240,34 @@
## Use image with Docker ## Use image with Docker
### Run in one click ### Create Docker Image
`docker run -it vgpastor/hackingtool` - Create the docker image
### Build locally ```bash
`docker-compose build` docker buitl -t vgpastor/hackingtool .
```
`docker-compose run hackingtool` ### Run as container
```bash
docker-compose up -d
```
### Interact with terminal
- Get into the container
```bash
docker exec -it hackingtool bash
```
**OUTPUT:**
```bash
Select Best Option :
[1] Kali Linux / Parrot-Os (apt)
[2] Arch Linux (pacman)
[0] Exit
```
Enter the options and continue.
- If need open other ports you can edit the docker-compose.yml file - If need open other ports you can edit the docker-compose.yml file
- Volumes are mounted in the container to persist data and can share files between the host and the container - Volumes are mounted in the container to persist data and can share files between the host and the container

View File

@ -1,9 +1,10 @@
version: "3.9" version: "3.9"
services: services:
hackingtool: hackingtool:
build: . image: vgpastor/hackingtool
stdin_open: true # docker run -i container_name: hackingtool
tty: true # docker run -t stdin_open: true
tty: true
volumes: volumes:
- .:/root/hackingtool - .:/root/hackingtool
ports: ports: