FROM --platform=linux/amd64 nginx:1.12-alpine

# Install openssl to generate self-signed certs
RUN apk add --no-cache openssl

# Create directory for SSL certs
RUN mkdir -p /etc/nginx/ssl

# Generate a self-signed certificate (valid for 365 days)
RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
    -keyout /etc/nginx/ssl/nginx.key \
    -out /etc/nginx/ssl/nginx.crt \
    -subj "/C=FR/ST=TPT/L=Lab/O=Telecom/CN=localhost"

# Copy vulnerable configuration
COPY nginx.conf /etc/nginx/nginx.conf

# Copy web content
COPY www /var/www

# Create a simple index.html if not exists (or overwrite)
RUN echo "<h1>Nginx Server</h1><p>This server is fonctionning properly.</p>" > /var/www/html/index.html
