Skip to content

Commit

Permalink
Revert "fix: use envsubst directly instead of nginx ssi"
Browse files Browse the repository at this point in the history
This reverts commit 31b175c.
  • Loading branch information
achauve committed Aug 19, 2024
1 parent 31b175c commit 0ec5125
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 76 deletions.
2 changes: 0 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@ docker-compose.yml
.kontinuous
.env
.husky

start.sh
30 changes: 13 additions & 17 deletions packages/frontend-usagers/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ ARG SENTRY_URL
ARG SENTRY_AUTH_TOKEN

# Runtime env variables set by Nginx injection
ENV NUXT_PUBLIC_APP_VERSION=\$ENV_NUXT_PUBLIC_APP_VERSION
ENV NUXT_PUBLIC_BACKEND_URL=\$ENV_NUXT_PUBLIC_BACKEND_URL
ENV NUXT_PUBLIC_ENVIRONMENT=\$ENV_NUXT_PUBLIC_ENVIRONMENT
ENV NUXT_PUBLIC_MATOMO_ENABLED=\$ENV_NUXT_PUBLIC_MATOMO_ENABLED
ENV NUXT_PUBLIC_MATOMO_HOST=\$ENV_NUXT_PUBLIC_MATOMO_HOST
ENV NUXT_PUBLIC_MATOMO_SITE_ID=\$ENV_NUXT_PUBLIC_MATOMO_SITE_ID
ENV NUXT_PUBLIC_SENTRY_DSN=\$ENV_NUXT_PUBLIC_SENTRY_DSN
ENV NUXT_PUBLIC_SENTRY_ENABLED=\$ENV_NUXT_PUBLIC_SENTRY_ENABLED
ENV NUXT_PUBLIC_APP_VERSION=ENV_NUXT_PUBLIC_APP_VERSION
ENV NUXT_PUBLIC_BACKEND_URL=ENV_NUXT_PUBLIC_BACKEND_URL
ENV NUXT_PUBLIC_ENVIRONMENT=ENV_NUXT_PUBLIC_ENVIRONMENT
ENV NUXT_PUBLIC_MATOMO_ENABLED=ENV_NUXT_PUBLIC_MATOMO_ENABLED
ENV NUXT_PUBLIC_MATOMO_HOST=ENV_NUXT_PUBLIC_MATOMO_HOST
ENV NUXT_PUBLIC_MATOMO_SITE_ID=ENV_NUXT_PUBLIC_MATOMO_SITE_ID
ENV NUXT_PUBLIC_SENTRY_DSN=ENV_NUXT_PUBLIC_SENTRY_DSN
ENV NUXT_PUBLIC_SENTRY_ENABLED=ENV_NUXT_PUBLIC_SENTRY_ENABLED

# Cannot be changed at runtime
ENV NUXT_PUBLIC_SENTRY_RELEASE=$SENTRY_RELEASE
Expand All @@ -45,18 +45,14 @@ RUN yarn workspace @vao/frontend-usagers generate
FROM nginxinc/nginx-unprivileged:1.27-alpine

COPY packages/frontend-usagers/nginx.conf /etc/nginx/nginx.conf
COPY packages/frontend-usagers/nginx.conf.template /etc/nginx/templates/default.conf.template

USER 0
# RUN chown -R nginx:nginx /usr/share/nginx/html && chmod -R 755 /usr/share/nginx/html \
# && chown -R nginx:nginx /etc/nginx

RUN chown -R 101:101 /usr/share/nginx/html
RUN chown -R nginx:nginx /usr/share/nginx/html && chmod -R 755 /usr/share/nginx/html \
&& chown -R nginx:nginx /etc/nginx

USER 101

CMD ["/app/start_nginx.sh"]
# CMD ["nginx", "-g", "daemon off;"]
#, "-T"]
CMD ["nginx", "-g", "daemon off;"]

COPY --from=builder --chown=101:101 /app/packages/frontend-usagers/.output/public /app
COPY --from=builder --chown=101:101 /app/packages/frontend-usagers/start_nginx.sh /app
COPY --from=builder --chown=101:101 /app/packages/frontend-usagers/.output/public /usr/share/nginx/html
31 changes: 1 addition & 30 deletions packages/frontend-usagers/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,5 @@ http {
keepalive_timeout 3000;
sendfile on;

server {
listen 8080;
root /usr/share/nginx/html;
index index.html;
server_name_in_redirect on;
add_header X-Frame-Options "deny";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
charset utf-8;
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_types text/css application/json application/javascript application/x-javascript text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon;
client_max_body_size 32m;
error_page 500 502 503 504 /50x.html;

location / {
# this always fallback on /index.html, never 404
try_files $uri $uri.html $uri/index.html $uri/ /index.html;
}

location /50x.html {
root /var/lib/nginx/html;
}
}
include /etc/nginx/conf.d/*.conf;
}
42 changes: 42 additions & 0 deletions packages/frontend-usagers/nginx.conf.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
server {

listen 8080;
root /usr/share/nginx/html;
index index.html;
server_name_in_redirect on;
add_header X-Frame-Options "deny";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
charset utf-8;
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_types text/css application/json application/javascript application/x-javascript text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon;
client_max_body_size 32m;
error_page 500 502 503 504 /50x.html;

location / {
ssi on;
ssi_types application/javascript application/x-javascript text/javascript;
set $ENV_NUXT_PUBLIC_APP_VERSION "$NUXT_PUBLIC_APP_VERSION";
set $ENV_NUXT_PUBLIC_BACKEND_URL "$NUXT_PUBLIC_BACKEND_URL";
set $ENV_NUXT_PUBLIC_ENVIRONMENT "$NUXT_PUBLIC_ENVIRONMENT";
set $ENV_NUXT_PUBLIC_MATOMO_ENABLED "$NUXT_PUBLIC_MATOMO_ENABLED";
set $ENV_NUXT_PUBLIC_MATOMO_HOST "$NUXT_PUBLIC_MATOMO_HOST";
set $ENV_NUXT_PUBLIC_MATOMO_SITE_ID "$NUXT_PUBLIC_MATOMO_SITE_ID";
set $ENV_NUXT_PUBLIC_SENTRY_DSN "$NUXT_PUBLIC_SENTRY_DSN";
set $ENV_NUXT_PUBLIC_SENTRY_ENABLED "$NUXT_PUBLIC_SENTRY_ENABLED";

# this always fallback on /index.html, never 404
try_files $uri $uri.html $uri/index.html $uri/ /index.html;
}

location /50x.html {
root /var/lib/nginx/html;
}
}
4 changes: 4 additions & 0 deletions packages/frontend-usagers/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

yarn workspace @vao/frontend-usagers install
exec yarn workspace @vao/frontend-usagers dev
27 changes: 0 additions & 27 deletions packages/frontend-usagers/start_nginx.sh

This file was deleted.

0 comments on commit 0ec5125

Please sign in to comment.