diff --git a/inventory.yaml b/ansible/inventory.yaml similarity index 100% rename from inventory.yaml rename to ansible/inventory.yaml diff --git a/ansible/playbooks/01_Setup_Docker.yaml b/ansible/playbooks/01_Setup_Docker.yaml new file mode 100644 index 0000000..e69de29 diff --git a/ansible/playbooks/02_deploy_snake_game.yaml b/ansible/playbooks/02_deploy_snake_game.yaml new file mode 100644 index 0000000..e69de29 diff --git a/ansible/playbooks/03_deploy_monitoring.yaml b/ansible/playbooks/03_deploy_monitoring.yaml new file mode 100644 index 0000000..e69de29 diff --git a/monitoring/docker-compose.yaml b/monitoring/docker-compose.yaml index 1c34462..ee621bd 100644 --- a/monitoring/docker-compose.yaml +++ b/monitoring/docker-compose.yaml @@ -4,39 +4,29 @@ services: image: prom/prometheus:latest volumes: - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro - - prometheus_data:/prometheus ports: - "9090:9090" networks: - - webnet + - snake_net restart: unless-stopped grafana: - image: grafana/grafana:9.0.0 + image: grafana/grafana:latest user: "472" volumes: - - grafana_data:/var/lib/grafana - ./grafana/provisioning:/etc/grafana/provisioning:ro + - grafana_data:/var/lib/grafana environment: GF_SECURITY_ADMIN_PASSWORD: "admin" ports: - "3000:3000" networks: - - webnet - restart: unless-stopped - - nginx_exporter: - image: nginx/nginx-prometheus-exporter:0.9.0 - environment: - SCRAPE_URI: http://snake:80/nginx_status - networks: - - webnet + - snake_net restart: unless-stopped volumes: - prometheus_data: grafana_data: networks: - webnet: + snake_net: external: true diff --git a/monitoring/prometheus.yaml b/monitoring/prometheus.yaml index e69de29..1a4f4ae 100644 --- a/monitoring/prometheus.yaml +++ b/monitoring/prometheus.yaml @@ -0,0 +1,7 @@ +global: + scrape_interval: 15s + +scrape_configs: + - job_name: 'snake_nginx' + static_configs: + - targets: ['213.95.90.157:81'] diff --git a/snake/Dockerfile b/snake/Dockerfile index 29f210e..9524304 100644 --- a/snake/Dockerfile +++ b/snake/Dockerfile @@ -1,22 +1,9 @@ -FROM alpine:latest +FROM nginx:stable-alpine -RUN apk add --no-cache nginx bash curl php82 php82-fpm php82-mysqli \ - php82-pdo php82-pdo_mysql php82-gd php82-opcache php82-session \ - php82-ctype php82-dom php82-mbstring php82-zlib php82-curl tar +# Copy Snake game HTML +COPY index.html /usr/share/nginx/html/index.html -# Verzeichnisse anlegen und Rechte setzen -RUN mkdir -p /run/nginx /var/log/nginx /var/www/html /data \ - && chmod o+rx /data \ - && chmod -R o+r /data \ - && rm -rf /var/www/html \ - && ln -s /data /var/www/html \ - && chown -R 101:101 /data - -# nginx config und Startskript kopieren +# Copy custom Nginx config with stub_status COPY nginx.conf /etc/nginx/nginx.conf -COPY start.sh /start.sh -RUN chmod +x /start.sh -EXPOSE 80 - -CMD ["/start.sh"] +EXPOSE 80 81 diff --git a/snake/nginx.conf b/snake/nginx.conf index d856bb8..d845475 100644 --- a/snake/nginx.conf +++ b/snake/nginx.conf @@ -1,40 +1,29 @@ -worker_processes auto; - -events { - worker_connections 1024; -} +worker_processes 1; +events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; - sendfile on; - keepalive_timeout 65; - client_max_body_size 100M; - - access_log /var/log/nginx/access.log; - error_log /var/log/nginx/error.log; - + # Snake game server server { listen 80; - server_name localhost; - - root /var/www/html; - index index.php index.html index.htm; + server_name _; location / { - try_files $uri $uri/ /index.php?$args; + root /usr/share/nginx/html; + index index.html; } + } - location ~ \.php$ { - fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_pass 127.0.0.1:9000; - fastcgi_index index.php; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - include fastcgi_params; - } + # Metrics for Prometheus + server { + listen 81; + server_name _; - location ~ /\.ht { + location /nginx_status { + stub_status; + allow 0.0.0.0/0; # adjust for security; or restrict to your Prometheus server deny all; } }