Skip to content

Commit 8f42046

Browse files
committed
Fixed #18 #23 in Dockerfile
1 parent bbd7288 commit 8f42046

1 file changed

Lines changed: 12 additions & 31 deletions

File tree

Dockerfile

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,18 @@ RUN apk add --no-cache curl jq && \
99
tar --strip-components=1 -xf /tmp/nodpi.tar
1010

1111
# Preparing run script
12-
RUN cat << 'EOF' > ./nodpi
13-
#!/bin/sh
14-
15-
# Get the absolute path of the script
16-
script_path="$(cd "$(dirname "$0")" && pwd)"
17-
18-
# Default blacklists file
19-
blacklist_file="$script_path/blacklist.txt"
20-
21-
# Optional directory containing additional blacklists
22-
blacklists_dir="/blacklists"
23-
24-
# Temporary file for the combined blacklist
25-
tmp_file="/tmp/blacklist.txt"
26-
27-
# Check if the directory with blacklists exists
28-
if [ -d "$blacklists_dir" ]; then
29-
# Concatenate all blacklist files from the directory into the temporary file
30-
cat "$blacklists_dir"/* > "$tmp_file" 2>/dev/null
31-
32-
# If the temporary file exists and is not empty, use it as the blacklist
33-
if [ -f "$tmp_file" ] && [ -s "$tmp_file" ]; then
34-
blacklist_file="$tmp_file"
35-
fi
36-
fi
37-
38-
# Run the main Python script with the specified blacklist file and pass all arguments
39-
python3 "$script_path/src/main.py" --host 0.0.0.0 --blacklist "$blacklist_file" "$@"
40-
41-
EOF
42-
12+
RUN echo '#!/bin/sh' > ./nodpi && \
13+
echo 'script_path="$(cd "$(dirname "$0")" && pwd)"' >> ./nodpi && \
14+
echo 'blacklist_file="$script_path/blacklist.txt"' >> ./nodpi && \
15+
echo 'blacklists_dir="/blacklists"' >> ./nodpi && \
16+
echo 'tmp_file="/tmp/blacklist.txt"' >> ./nodpi && \
17+
echo 'if [ -d "$blacklists_dir" ]; then' >> ./nodpi && \
18+
echo ' cat "$blacklists_dir"/* > "$tmp_file" 2>/dev/null' >> ./nodpi && \
19+
echo ' if [ -f "$tmp_file" ] && [ -s "$tmp_file" ]; then' >> ./nodpi && \
20+
echo ' blacklist_file="$tmp_file"' >> ./nodpi && \
21+
echo ' fi' >> ./nodpi && \
22+
echo 'fi' >> ./nodpi && \
23+
echo 'python3 "$script_path/src/main.py" --host 0.0.0.0 --blacklist "$blacklist_file" "$@"' >> ./nodpi
4324
RUN chmod +x ./nodpi
4425

4526
# App runner

0 commit comments

Comments
 (0)