Enable GZIP for Nginx
This commit is contained in:
+4
-3
@@ -9,7 +9,7 @@ ENV FLUTTER_HOME="/opt/flutter"
|
||||
ENV PATH "$PATH:$FLUTTER_HOME/bin"
|
||||
|
||||
# Prerequisites
|
||||
RUN apt update && apt install -y curl git unzip xz-utils zip libglu1-mesa \
|
||||
RUN apt update && apt install -y curl git unzip xz-utils zip gzip libglu1-mesa \
|
||||
&& mkdir -p $FLUTTER_HOME \
|
||||
&& curl -o flutter.tar.xz $FLUTTER_URL \
|
||||
&& tar xf flutter.tar.xz -C /opt \
|
||||
@@ -30,12 +30,13 @@ RUN cd core \
|
||||
&& cd .. \
|
||||
&& flutter pub get && flutter pub run intl_generator:extract_to_arb --output-dir=./lib/l10n lib/main/localizations/app_localizations.dart \
|
||||
&& flutter pub get && flutter pub run intl_generator:generate_from_arb --output-dir=lib/l10n --no-use-deferred-loading lib/main/localizations/app_localizations.dart lib/l10n/intl*.arb \
|
||||
&& flutter build web --profile
|
||||
&& flutter build web --profile \
|
||||
&& gzip -r -k /app/build/web
|
||||
|
||||
# Stage 2 - Create the run-time image
|
||||
FROM nginx:stable
|
||||
RUN chmod -R 755 /usr/share/nginx/html
|
||||
COPY --from=build-env /app/server/nginx.conf /usr/share/nginx/html
|
||||
COPY --from=build-env /app/server/nginx.conf /etc/nginx
|
||||
COPY --from=build-env /app/build/web /usr/share/nginx/html
|
||||
|
||||
# Record the exposed port
|
||||
|
||||
+43
-11
@@ -1,17 +1,49 @@
|
||||
server {
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
|
||||
listen 80;
|
||||
error_log /var/log/nginx/error.log notice;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
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;
|
||||
|
||||
sendfile on;
|
||||
#tcp_nopush on;
|
||||
|
||||
keepalive_timeout 65;
|
||||
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
}
|
||||
|
||||
gzip_static on;
|
||||
gzip_disable "msie6";
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_http_version 1.1;
|
||||
}
|
||||
Reference in New Issue
Block a user