FROM nginx:alpine

# Copy website files to nginx html directory
COPY index.html /usr/share/nginx/html/
COPY styles.css /usr/share/nginx/html/
COPY script.js /usr/share/nginx/html/
# Include Solana dApp files
COPY solana.html /usr/share/nginx/html/
COPY solana.js /usr/share/nginx/html/

# Create assets directory and copy source files
RUN mkdir -p /usr/share/nginx/html/assets
COPY assets/ /usr/share/nginx/html/assets/

# Copy custom nginx configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf

# Create robots.txt and sitemap.xml
RUN echo -e "User-agent: *\nAllow: /\n\nSitemap: /sitemap.xml" > /usr/share/nginx/html/robots.txt

RUN echo -e '<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n  <url>\n    <loc>https://your-domain.com/</loc>\n    <lastmod>2024-10-05</lastmod>\n    <changefreq>weekly</changefreq>\n    <priority>1.0</priority>\n  </url>\n</urlset>' > /usr/share/nginx/html/sitemap.xml

# Set proper permissions
RUN chown -R nginx:nginx /usr/share/nginx/html && \
    chmod -R 644 /usr/share/nginx/html/* && \
    chmod 755 /usr/share/nginx/html/

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]