dns-host / Dockerfile
privateone's picture
Upload 5 files
9c087ca verified
# Use latest Alpine as base image
FROM alpine:latest
# Maintainer info
LABEL maintainer="you@example.com"
# Enable Alpine edge community repo for dotnet8 packages
RUN echo "https://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories && \
apk update
# Install necessary packages: dotnet8-runtime, aspnetcore8-runtime, supervisor, and nginx
RUN apk add --no-cache \
tar \
wget \
nginx \
tzdata \
supervisor \
dotnet8-runtime \
aspnetcore8-runtime
# Create a non-root user and group
RUN addgroup -S app_admin && adduser -S app_user -G app_admin
# Set environment variables
ENV HOME=/home/app_user \
PATH=/home/app_user/.local/bin:$PATH
# Create necessary directories with proper permissions
RUN mkdir -p /app /app/dns-server /opt/technitium/dns /var/log /var/lib/logs /tmp && \
touch /app/supervisord.log /app/supervisord.pid /app/nginx.pid && \
chmod 777 /app/supervisord.log /app/supervisord.pid /app/nginx.pid && \
chown -R app_user:app_admin /app /var/log /var/lib/logs/ /tmp && \
chmod -R 755 /app /tmp && \
chmod -R 777 /var/log
RUN mkdir -p /var/log/nginx /run/nginx && \
chown -R app_user:app_admin /var/lib/nginx /var/log/nginx
# Copy the application files into the container with proper ownership
COPY --chown=app_user:app_admin . $HOME/app
# Copy the Nginx configuration file
COPY --chown=app_user:app_admin ./nginx.conf /etc/nginx/conf.d/nginx.conf
COPY --chown=app_user:app_admin ./nginx.conf /etc/nginx/nginx.conf
# Copy the supervisord configuration file
COPY --chown=app_user:app_admin ./supervisord.conf /etc/supervisord.conf
# Download Technitium DNS Server and extract
RUN wget https://download.technitium.com/dns/DnsServerPortable.tar.gz -O /tmp/DnsServerPortable.tar.gz && \
mkdir -p /app/dns-server && \
tar -zxf /tmp/DnsServerPortable.tar.gz -C /app/dns-server && \
rm -rf /tmp/DnsServerPortable.tar.gz
# Set working directory for DNS Server
WORKDIR /app
# Expose the necessary ports
EXPOSE 7860
# Switch to non-root user
USER app_user
# Start Supervisor to manage services
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]