Skip to content

Commit 48f6c28

Browse files
authored
Merge pull request #334 from NOXCIS/main
Fixed Docker Image
2 parents 84cf4a9 + 0c1502f commit 48f6c28

File tree

12 files changed

+293
-222
lines changed

12 files changed

+293
-222
lines changed

.github/workflows/main.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Docker Image Build and Analysis
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * *" # Schedule the workflow to run daily at midnight (UTC time). Adjust the time if needed.
6+
workflow_dispatch: # Manual run trigger
7+
inputs:
8+
trigger-build:
9+
description: 'Trigger a manual build and push'
10+
default: 'true'
11+
12+
jobs:
13+
build-and-analyze:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v3
19+
20+
- name: Log in to Docker Hub
21+
uses: docker/login-action@v3
22+
with:
23+
username: ${{ secrets.DOCKERHUB_USERNAME }}
24+
password: ${{ secrets.DOCKERHUB_TOKEN }}
25+
26+
- name: Build Docker image
27+
id: build-image
28+
run: |
29+
echo "Building Docker image..."
30+
docker build -t my-app-image:latest .
31+
echo "Docker image built successfully."
32+
33+
- name: Install Docker Scout
34+
run: |
35+
echo "Installing Docker Scout..."
36+
curl -sSfL https://raw.githubusercontent.com/docker/scout-cli/main/install.sh | sh -s --
37+
echo "Docker Scout installed successfully."
38+
39+
- name: Analyze Docker image with Docker Scout
40+
id: analyze-image
41+
run: |
42+
echo "Analyzing Docker image with Docker Scout..."
43+
docker scout cves my-app-image:latest > scout-results.txt
44+
cat scout-results.txt # Print the report to the workflow logs for easy viewing
45+
echo "Docker Scout analysis completed."
46+
47+
- name: Post Comment on Issue or PR
48+
run: |
49+
COMMENT="**Docker Image Build and Analysis Report**\n\nThe Docker image was built and analyzed successfully.\n\n**Build Summary:**\n- Image Tag: my-app-image:latest\n\n**Analysis Report:**\n\`\`\`\n$(cat scout-results.txt)\n\`\`\`"
50+
51+
# Post comment using GitHub API
52+
curl -X POST \
53+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
54+
-H "Accept: application/vnd.github.v3+json" \
55+
-d "{\"body\": \"$COMMENT\"}" \
56+
"https://api.github.com/repos/NOXCIS/WGDashboard/issues/1/comments" # Replace '1' with the issue or PR number

Dockerfile

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Pull from small Debian stable image.
2+
FROM alpine:latest AS builder
3+
4+
LABEL maintainer="[email protected]"
5+
6+
WORKDIR /opt/wireguarddashboard/src
7+
8+
RUN apk update && \
9+
apk add --no-cache sudo gcc musl-dev rust cargo linux-headers
10+
11+
COPY ./docker/alpine/builder.sh /opt/wireguarddashboard/src/
12+
COPY ./docker/alpine/requirements.txt /opt/wireguarddashboard/src/
13+
RUN chmod u+x /opt/wireguarddashboard/src/builder.sh
14+
RUN /opt/wireguarddashboard/src/builder.sh
15+
16+
17+
FROM alpine:latest
18+
WORKDIR /opt/wireguarddashboard/src
19+
20+
COPY ./src /opt/wireguarddashboard/src/
21+
COPY --from=builder /opt/wireguarddashboard/src/venv /opt/wireguarddashboard/src/venv
22+
COPY --from=builder /opt/wireguarddashboard/src/log /opt/wireguarddashboard/src/log/
23+
24+
RUN apk update && \
25+
apk add --no-cache wireguard-tools sudo && \
26+
apk add --no-cache iptables ip6tables && \
27+
chmod u+x /opt/wireguarddashboard/src/entrypoint.sh
28+
29+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 CMD curl -f http://localhost:10086/signin || exit 1
30+
31+
ENTRYPOINT ["/opt/wireguarddashboard/src/entrypoint.sh"]

compose.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
services:
2+
3+
wireguard-dashboard:
4+
build: ./
5+
container_name: wiregate
6+
cap_add:
7+
- NET_ADMIN
8+
- SYS_MODULE
9+
restart: unless-stopped
10+
environment:
11+
- wg_net=10.0.0.1/24
12+
- wg_port=51820
13+
volumes:
14+
- wgd_configs:/etc/wireguard
15+
- wgd_app:/opt/wireguarddashboard/src
16+
ports:
17+
- 10086:10086/tcp
18+
- 51820:51820/udp
19+
sysctls:
20+
- net.ipv4.ip_forward=1
21+
- net.ipv4.conf.all.src_valid_mark=1
22+
23+
24+
volumes:
25+
wgd_configs:
26+
wgd_app:

docker/Dockerfile

-77
This file was deleted.

docker/alpine/builder.sh

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
venv_python="./venv/bin/python3"
2+
venv_gunicorn="./venv/bin/gunicorn"
3+
pythonExecutable="python3"
4+
5+
6+
_check_and_set_venv(){
7+
VIRTUAL_ENV="./venv"
8+
if [ ! -d $VIRTUAL_ENV ]; then
9+
printf "[WGDashboard] Creating Python Virtual Environment under ./venv\n"
10+
{ $pythonExecutable -m venv $VIRTUAL_ENV; } >> ./log/install.txt
11+
fi
12+
13+
if ! $venv_python --version > /dev/null 2>&1
14+
then
15+
printf "[WGDashboard] %s Python Virtual Environment under ./venv failed to create. Halting now.\n" "$heavy_crossmark"
16+
kill $TOP_PID
17+
fi
18+
19+
source ${VIRTUAL_ENV}/bin/activate
20+
21+
}
22+
23+
build_core () {
24+
if [ ! -d "log" ]
25+
then
26+
printf "[WGDashboard] Creating ./log folder\n"
27+
mkdir "log"
28+
fi
29+
30+
31+
apk add --no-cache python3 net-tools python3-dev py3-virtualenv
32+
_check_and_set_venv
33+
printf "[WGDashboard] Upgrading Python Package Manage (PIP)\n"
34+
{ date; python3 -m pip install --upgrade pip; printf "\n\n"; } >> ./log/install.txt
35+
printf "[WGDashboard] Building Bcrypt & Psutil\n"
36+
{ date; python3 -m pip install -r requirements.txt ; printf "\n\n"; } >> ./log/install.txt
37+
printf "[WGDashboard] Build Successfull!\n"
38+
printf "[WGDashboard] Clean Up Pip!\n"
39+
{ date; rm -rf /opt/wireguarddashboard/src/venv/lib/python3.12/site-packages/pip* ; printf "\n\n"; } >> ./log/install.txt
40+
41+
}
42+
43+
build_core

docker/alpine/requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bcrypt
2+
psutil

docker/compose.yaml

-23
This file was deleted.

docker/entrypoint.sh

-109
This file was deleted.

0 commit comments

Comments
 (0)