Skip to content

Commit

Permalink
update: docker
Browse files Browse the repository at this point in the history
  • Loading branch information
euandrelucas committed Feb 13, 2024
1 parent 11b0e1d commit 35d6666
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 43 deletions.
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ RUN npm run build
# Use the official Nginx base image
FROM nginx:latest

# Install Jemalloc
RUN apt-get update && apt-get install libjemalloc-dev -y && apt-get clean
ENV LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libjemalloc.so"

# Remove the default Nginx configuration
RUN rm /etc/nginx/conf.d/default.conf

Expand All @@ -37,4 +41,4 @@ COPY --from=0 /usr/src/app/dist /usr/share/nginx/html
EXPOSE 80

# Start Nginx
CMD ["nginx", "-g", "daemon off;"]
CMD ["LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2", "nginx", "-g", "daemon off;"]
41 changes: 41 additions & 0 deletions default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
server {
listen 80;
server_name localhost;

client_body_timeout 10s;
client_header_timeout 10s;
send_timeout 10s;

location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;
limit_req zone=one burst=5 nodelay;
limit_conn conn_limit_per_ip 10;

location ~* \.(js|css|png|jpg|jpeg|gif|ico|webp)$ {
expires 4h;
add_header Cache-Control "public, max-age=14400";
}

location ~* \.(webp)$ {
expires 4h;
add_header Cache-Control "public, max-age=14400";
}

location ~* rocket-loader\.min\.js$ {
expires 2d;
add_header Cache-Control "public, max-age=172800";
}

location ~* avatars\.githubusercontent\.com {
expires 5m;
add_header Cache-Control "public, max-age=300";
}

location ~* shields\.io {
expires 1d;
add_header Cache-Control "public, max-age=86400";
}
}
}
43 changes: 1 addition & 42 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -1,46 +1,5 @@
http {
limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;

server {
listen 80;
server_name localhost;

client_body_timeout 10s;
client_header_timeout 10s;
send_timeout 10s;

location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;
limit_req zone=one burst=5 nodelay;
limit_conn conn_limit_per_ip 10;

location ~* \.(js|css|png|jpg|jpeg|gif|ico|webp)$ {
expires 4h;
add_header Cache-Control "public, max-age=14400";
}

location ~* \.(webp)$ {
expires 4h;
add_header Cache-Control "public, max-age=14400";
}

location ~* rocket-loader\.min\.js$ {
expires 2d;
add_header Cache-Control "public, max-age=172800";
}

location ~* avatars\.githubusercontent\.com {
expires 5m;
add_header Cache-Control "public, max-age=300";
}

location ~* shields\.io {
expires 1d;
add_header Cache-Control "public, max-age=86400";
}
}
}
include /etc/nginx/conf.d/*.conf;
}

0 comments on commit 35d6666

Please sign in to comment.