Skip to content

Commit

Permalink
Merge pull request #14 from devxp-tech/hotfix/devspace/helm
Browse files Browse the repository at this point in the history
Hotfix/devspace/helm
  • Loading branch information
diegoluisi authored Jun 8, 2024
2 parents 3fee27e + 2f5eea9 commit cc5d301
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 89 deletions.
36 changes: 26 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
FROM nginx/nginx-prometheus-exporter as exporter
# Use the official Nginx base image
FROM nginx:alpine

ENV PORT 80
# Install curl to fetch nginx-prometheus-exporter
RUN apk add --no-cache curl tar

WORKDIR /app
# Set the version of nginx-prometheus-exporter to install
ENV NGINX_PROMETHEUS_EXPORTER_VERSION=1.1.2

COPY app/ /usr/share/nginx/html
# copy config and exporter
COPY --from=exporter /usr/bin/nginx-prometheus-exporter /usr/bin/nginx-prometheus-exporter
# Download and install nginx-prometheus-exporter
RUN curl -L https://github.com/nginxinc/nginx-prometheus-exporter/releases/download/v${NGINX_PROMETHEUS_EXPORTER_VERSION}/nginx-prometheus-exporter_${NGINX_PROMETHEUS_EXPORTER_VERSION}_linux_amd64.tar.gz \
| tar -zx -C /usr/local/bin

# Copy the static application files to the Nginx document root
COPY ./app /usr/share/nginx/html

# Copy the health check file
COPY health-check/liveness/index.html /usr/share/nginx/html/health-check/liveness/index.html
COPY health-check/readness/index.html /usr/share/nginx/html/health-check/readness/index.html


# Copy the custom Nginx configuration
COPY conf/nginx.conf /etc/nginx/nginx.conf
COPY conf/supervisor.conf /etc/supervisor/supervisor.conf
COPY conf/default.conf /etc/nginx/conf.d/default.conf
COPY conf/stub_status.conf /etc/nginx/conf.d/stub_status.conf

RUN apk add --no-cache supervisor
# Expose ports for Nginx and Prometheus metrics
EXPOSE 80 9090

# Add a health check instruction
HEALTHCHECK --interval=30s --timeout=5s --retries=3 CMD curl -f http://localhost/health-check/liveness || exit 1

EXPOSE 80 9113
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisor.conf"]
# Start Nginx and nginx-prometheus-exporter
CMD ["sh", "-c", "nginx -g 'daemon off;' & nginx-prometheus-exporter -nginx.scrape-uri http://127.0.0.1:8080/stub_status -web.listen-address :9090"]
13 changes: 13 additions & 0 deletions conf/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
server {
listen 80;
location / {
root /usr/share/nginx/html;
index index.html;
}
location /health-check/liveness {
alias /usr/share/nginx/html/health-check/liveness/;
}
location /health-check/readness {
alias /usr/share/nginx/html/health-check/readness/;
}
}
90 changes: 18 additions & 72 deletions conf/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,81 +1,27 @@
user nginx;
worker_processes auto;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

events {
worker_connections 1024;
worker_connections 1024;
}

include /etc/nginx/conf.d/*-root.conf;

http {
server_tokens off;
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

keepalive_timeout 65;
sendfile on;
tcp_nopush on;
port_in_redirect off;

server {
listen 80;
charset utf-8;
server_name _;

real_ip_header x-forwarded-for;
set_real_ip_from 0.0.0.0/0;
real_ip_recursive on;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

root /app/dist;
index index.html;
access_log /var/log/nginx/access.log main;

location ~ /\. {
deny all;
access_log off;
log_not_found off;
return 404;
}
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;

location ~* \.(?:css|js)$ {
access_log off;
log_not_found off;
add_header Cache-Control "no-cache, public, must-revalidate, proxy-revalidate";
}
include /etc/nginx/mime.types;
default_type application/octet-stream;

location ~* \.(?:jpg|jpeg|gif|png|ico|xml|webp|eot|woff|woff2|ttf|svg|otf)$ {
access_log off;
log_not_found off;
expires 60m;
add_header Cache-Control "public";
}

location / {
try_files $uri $uri/ /;
}

include /etc/nginx/conf.d/*-server.conf;

}

# metrics
server {
listen 8000;
server_name _;

location /stub_status {
stub_status on;
access_log off;
}
}

include /etc/nginx/conf.d/*-http.conf;
}
include /etc/nginx/conf.d/*.conf;
}
8 changes: 8 additions & 0 deletions conf/stub_status.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
server {
listen 8080;
location /stub_status {
stub_status;
allow 127.0.0.1;
deny all;
}
}
7 changes: 0 additions & 7 deletions conf/supervisor.conf

This file was deleted.

1 change: 1 addition & 0 deletions health-check/liveness/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
healthy
1 change: 1 addition & 0 deletions health-check/readness/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ready

0 comments on commit cc5d301

Please sign in to comment.