privateone commited on
Commit
9c087ca
·
verified ·
1 Parent(s): 5a36927

Upload 5 files

Browse files
Files changed (5) hide show
  1. Dockerfile +65 -0
  2. app_startup.sh +16 -0
  3. dns_startup.sh +22 -0
  4. nginx.conf +74 -0
  5. supervisord.conf +28 -0
Dockerfile ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use latest Alpine as base image
2
+ FROM alpine:latest
3
+
4
+ # Maintainer info
5
+ LABEL maintainer="you@example.com"
6
+
7
+ # Enable Alpine edge community repo for dotnet8 packages
8
+ RUN echo "https://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories && \
9
+ apk update
10
+
11
+ # Install necessary packages: dotnet8-runtime, aspnetcore8-runtime, supervisor, and nginx
12
+ RUN apk add --no-cache \
13
+ tar \
14
+ wget \
15
+ nginx \
16
+ tzdata \
17
+ supervisor \
18
+ dotnet8-runtime \
19
+ aspnetcore8-runtime
20
+
21
+ # Create a non-root user and group
22
+ RUN addgroup -S app_admin && adduser -S app_user -G app_admin
23
+
24
+ # Set environment variables
25
+ ENV HOME=/home/app_user \
26
+ PATH=/home/app_user/.local/bin:$PATH
27
+
28
+ # Create necessary directories with proper permissions
29
+ RUN mkdir -p /app /app/dns-server /opt/technitium/dns /var/log /var/lib/logs /tmp && \
30
+ touch /app/supervisord.log /app/supervisord.pid /app/nginx.pid && \
31
+ chmod 777 /app/supervisord.log /app/supervisord.pid /app/nginx.pid && \
32
+ chown -R app_user:app_admin /app /var/log /var/lib/logs/ /tmp && \
33
+ chmod -R 755 /app /tmp && \
34
+ chmod -R 777 /var/log
35
+
36
+ RUN mkdir -p /var/log/nginx /run/nginx && \
37
+ chown -R app_user:app_admin /var/lib/nginx /var/log/nginx
38
+
39
+ # Copy the application files into the container with proper ownership
40
+ COPY --chown=app_user:app_admin . $HOME/app
41
+
42
+ # Copy the Nginx configuration file
43
+ COPY --chown=app_user:app_admin ./nginx.conf /etc/nginx/conf.d/nginx.conf
44
+ COPY --chown=app_user:app_admin ./nginx.conf /etc/nginx/nginx.conf
45
+
46
+ # Copy the supervisord configuration file
47
+ COPY --chown=app_user:app_admin ./supervisord.conf /etc/supervisord.conf
48
+
49
+ # Download Technitium DNS Server and extract
50
+ RUN wget https://download.technitium.com/dns/DnsServerPortable.tar.gz -O /tmp/DnsServerPortable.tar.gz && \
51
+ mkdir -p /app/dns-server && \
52
+ tar -zxf /tmp/DnsServerPortable.tar.gz -C /app/dns-server && \
53
+ rm -rf /tmp/DnsServerPortable.tar.gz
54
+
55
+ # Set working directory for DNS Server
56
+ WORKDIR /app
57
+
58
+ # Expose the necessary ports
59
+ EXPOSE 7860
60
+
61
+ # Switch to non-root user
62
+ USER app_user
63
+
64
+ # Start Supervisor to manage services
65
+ CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]
app_startup.sh ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ set -e
3
+
4
+ echo "Setting up logs and supervisord..."
5
+ # Create /var/log directory if missing and set permissions
6
+
7
+ # Make sure DNS server start/stop scripts are executable
8
+ #chmod +x /app/dns-server/start.sh
9
+
10
+ # List all files inside /app to verify
11
+ echo "Listing files inside /app:"
12
+ ls -la /app
13
+
14
+ echo "Starting supervisord..."
15
+ /usr/bin/supervisord -c /etc/supervisord.conf -n
16
+
dns_startup.sh ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ # Start the Technitium DNS Server
3
+
4
+ # Log the start of the script
5
+ echo "Starting DNS server..."
6
+
7
+ # Ensure we are in the correct directory
8
+ cd /app/dns-server
9
+ echo "Changed directory to /app/dns-server
10
+
11
+ # Log before starting the DNS server
12
+ echo "Starting DnsServer.exe..."
13
+
14
+ # Start the DNS server
15
+ echo "Listing files inside /app:"
16
+ ls -la /app
17
+
18
+ ./start.sh
19
+
20
+ # Log after the server starts (if it gets this far)
21
+ echo "DnsServer.exe has started."
22
+
nginx.conf ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ worker_processes auto;
2
+
3
+ error_log stderr notice;
4
+ pid /app/nginx.pid;
5
+
6
+ events {
7
+ worker_connections 10;
8
+ }
9
+
10
+ http {
11
+ server {
12
+ listen 7860;
13
+
14
+ location = / {
15
+ default_type text/plain;
16
+ return 200 'hello';
17
+ }
18
+
19
+ # Main App Route (HTTP on port 7860)
20
+ location = /app {
21
+ proxy_pass http://127.0.0.1:8000; # Main app service (replace with your actual backend)
22
+ proxy_set_header X-Real-IP $remote_addr;
23
+ proxy_set_header Host $host;
24
+ proxy_set_header X-Forwarded-Proto $scheme;
25
+ proxy_http_version 1.1;
26
+ proxy_set_header Upgrade $http_upgrade;
27
+ proxy_set_header Connection "upgrade";
28
+ }
29
+
30
+ # DNS-over-HTTP Route (PathPrefix /dns-http on port 7860)
31
+ location /dns-http/ {
32
+ proxy_pass http://127.0.0.1:5380; # Replace "dns-server" with actual service name
33
+ proxy_set_header X-Real-IP $remote_addr;
34
+ proxy_set_header Host $host;
35
+ proxy_set_header X-Forwarded-Proto $scheme;
36
+ proxy_http_version 1.1;
37
+ proxy_set_header Upgrade $http_upgrade;
38
+ proxy_set_header Connection "upgrade";
39
+ }
40
+
41
+ # DNS-over-HTTPS Route (PathPrefix /dns-https on port 7860)
42
+ location /dns-https/ {
43
+ proxy_pass http://127.0.0.1:5381; # Replace "dns-server" with actual service name
44
+ proxy_set_header X-Real-IP $remote_addr;
45
+ proxy_set_header Host $host;
46
+ proxy_set_header X-Forwarded-Proto $scheme;
47
+ proxy_http_version 1.1;
48
+ proxy_set_header Upgrade $http_upgrade;
49
+ proxy_set_header Connection "upgrade";
50
+ }
51
+
52
+ # DNS-over-TLS Route (PathPrefix /dns-tls on port 7860)
53
+ location /dns-tls/ {
54
+ proxy_pass http://127.0.0.1:853; # Replace "dns-server" with actual service name
55
+ proxy_set_header X-Real-IP $remote_addr;
56
+ proxy_set_header Host $host;
57
+ proxy_set_header X-Forwarded-Proto $scheme;
58
+ proxy_http_version 1.1;
59
+ proxy_set_header Upgrade $http_upgrade;
60
+ proxy_set_header Connection "upgrade";
61
+ }
62
+
63
+ # Traefik Dashboard Route (PathPrefix /dashboard)
64
+ location /dashboard/ {
65
+ proxy_pass http://127.0.0.1:8080; # Assuming Traefik Dashboard is served locally on port 8080
66
+ proxy_set_header X-Real-IP $remote_addr;
67
+ proxy_set_header Host $host;
68
+ proxy_set_header X-Forwarded-Proto $scheme;
69
+ proxy_http_version 1.1;
70
+ proxy_set_header Upgrade $http_upgrade;
71
+ proxy_set_header Connection "upgrade";
72
+ }
73
+ }
74
+ }
supervisord.conf ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [supervisord]
2
+ loglevel=debug
3
+ nodaemon=true
4
+ logfile=/dev/stderr
5
+ pidfile=/app/supervisord.pid
6
+ # Increase file descriptor limit if needed
7
+ rlimit_nofile=65535
8
+
9
+ [program:nginx]
10
+ command=nginx -g "daemon off;"
11
+ # autorestart=true
12
+ # Discard stderr logs (won't be saved)
13
+ stderr_logfile=/dev/null
14
+ # Discard stdout logs (won't be saved)
15
+ stdout_logfile=/dev/null
16
+ user=app_user
17
+ priority=1
18
+
19
+ [program:dns]
20
+ command=dotnet /app/dns-server/DnsServerApp.dll
21
+ # autorestart=true
22
+ # Discard stderr logs (won't be saved)
23
+ stderr_logfile=/dev/null
24
+ # Discard stdout logs (won't be saved)
25
+ stdout_logfile=/dev/null
26
+ user=app_user
27
+ priority=10
28
+ startretries=3