Updatre frontend Dockerfile
This commit is contained in:
parent
ef79895358
commit
1d320f7284
@ -23,31 +23,32 @@ RUN npm run build
|
|||||||
# Production stage
|
# Production stage
|
||||||
FROM nginx:alpine
|
FROM nginx:alpine
|
||||||
|
|
||||||
# Copy custom nginx config
|
# Remove default nginx config
|
||||||
COPY <<EOF /etc/nginx/conf.d/default.conf
|
RUN rm /etc/nginx/conf.d/default.conf
|
||||||
server {
|
|
||||||
listen 80;
|
|
||||||
server_name _;
|
|
||||||
root /usr/share/nginx/html;
|
|
||||||
index index.html;
|
|
||||||
|
|
||||||
# Enable gzip compression
|
# Create custom nginx config
|
||||||
gzip on;
|
RUN echo 'server {' > /etc/nginx/conf.d/default.conf && \
|
||||||
gzip_vary on;
|
echo ' listen 80;' >> /etc/nginx/conf.d/default.conf && \
|
||||||
gzip_min_length 1024;
|
echo ' server_name _;' >> /etc/nginx/conf.d/default.conf && \
|
||||||
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/json;
|
echo ' root /usr/share/nginx/html;' >> /etc/nginx/conf.d/default.conf && \
|
||||||
|
echo ' index index.html;' >> /etc/nginx/conf.d/default.conf && \
|
||||||
location / {
|
echo '' >> /etc/nginx/conf.d/default.conf && \
|
||||||
try_files \$uri \$uri/ /index.html;
|
echo ' # Enable gzip compression' >> /etc/nginx/conf.d/default.conf && \
|
||||||
}
|
echo ' gzip on;' >> /etc/nginx/conf.d/default.conf && \
|
||||||
|
echo ' gzip_vary on;' >> /etc/nginx/conf.d/default.conf && \
|
||||||
# Cache static assets
|
echo ' gzip_min_length 1024;' >> /etc/nginx/conf.d/default.conf && \
|
||||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
echo ' gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/json;' >> /etc/nginx/conf.d/default.conf && \
|
||||||
expires 1y;
|
echo '' >> /etc/nginx/conf.d/default.conf && \
|
||||||
add_header Cache-Control "public, immutable";
|
echo ' location / {' >> /etc/nginx/conf.d/default.conf && \
|
||||||
}
|
echo ' try_files $uri $uri/ /index.html;' >> /etc/nginx/conf.d/default.conf && \
|
||||||
}
|
echo ' }' >> /etc/nginx/conf.d/default.conf && \
|
||||||
EOF
|
echo '' >> /etc/nginx/conf.d/default.conf && \
|
||||||
|
echo ' # Cache static assets' >> /etc/nginx/conf.d/default.conf && \
|
||||||
|
echo ' location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {' >> /etc/nginx/conf.d/default.conf && \
|
||||||
|
echo ' expires 1y;' >> /etc/nginx/conf.d/default.conf && \
|
||||||
|
echo ' add_header Cache-Control "public, immutable";' >> /etc/nginx/conf.d/default.conf && \
|
||||||
|
echo ' }' >> /etc/nginx/conf.d/default.conf && \
|
||||||
|
echo '}' >> /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
# Copy built files from build stage
|
# Copy built files from build stage
|
||||||
COPY --from=build /app/dist /usr/share/nginx/html
|
COPY --from=build /app/dist /usr/share/nginx/html
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user