Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat implem matomo improve dockerfile #82

Open
wants to merge 10 commits into
base: Platine-Access-V2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ VITE_OIDC_ISSUER=https://localhost:3000
VITE_OIDC_CLIENT_ID=myclient
VITE_AUTH_TYPE=oidc
VITE_PORTAIL_URL=https://localhost:3000
VITE_APP_URL=https://localhost:3000
VITE_APP_URL=https://localhost:3000
VITE_TRACKING_URL=
25 changes: 17 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
FROM nginx
RUN rm -rf /usr/share/nginx/html/*
FROM nginxinc/nginx-unprivileged:1.27-alpine

ADD build /usr/share/nginx/html
# Non root user
ENV NGINX_USER_ID=101
ENV NGINX_GROUP_ID=101
ENV NGINX_USER=nginx

USER $NGINX_USER_ID

# Add build to nginx root webapp
COPY --chown=$NGINX_USER:$NGINX_USER dist /usr/share/nginx/html

# Copy nginx configuration
RUN rm etc/nginx/conf.d/default.conf
COPY nginx.conf etc/nginx/conf.d/
COPY --chown=$NGINX_USER:$NGINX_USER container/nginx.conf etc/nginx/conf.d/
RUN chmod 755 /usr/share/nginx/html/vite-envs.sh

COPY entrypoint.sh /entrypoint.sh
RUN chmod 755 /entrypoint.sh
ENTRYPOINT [ "/entrypoint.sh" ]
USER $NGINX_USER_ID
EXPOSE 8080

CMD ["nginx", "-g", "daemon off;"]
ENTRYPOINT sh -c "/usr/share/nginx/html/vite-envs.sh && nginx -g 'daemon off;'"
29 changes: 29 additions & 0 deletions container/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
server {
listen 8080;
server_name /usr/share/nginx/html;

root /usr/share/nginx/html;
index index.html;

location ~* \.(?:manifest|appcache|html?|xml|json)$ {
expires -1;
# access_log logs/static.log; # I don't usually include a static log
}

location ~* \.(?:css|js)$ {
try_files $uri =404;
expires 1y;
access_log off;
add_header Cache-Control "public";
}

# Any route containing a file extension (e.g. /devicesfile.js)
location ~ ^.+\..+$ {
try_files $uri =404;
}

# Any route that doesn't have a file extension (e.g. /devices)
location / {
try_files $uri $uri/ /index.html;
}
}
34 changes: 25 additions & 9 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,41 @@

<meta name="description" content="Portail de réponse aux enquêtes de la statistique publique" />

<link rel="apple-touch-icon" href="/dsfr/favicon/apple-touch-icon.png" />
<link rel="icon" href="/dsfr/favicon/favicon.svg" type="image/svg+xml" />
<link rel="shortcut icon" href="/dsfr/favicon/favicon.ico" type="image/x-icon" />
<link rel="manifest" href="/dsfr/favicon/manifest.webmanifest" crossorigin="use-credentials" />
<link rel="apple-touch-icon" href="/dsfr/favicon/apple-touch-icon.png?v=1.12.1" />
<link rel="icon" href="/dsfr/favicon/favicon.svg?v=1.12.1" type="image/svg+xml" />
<link rel="shortcut icon" href="/dsfr/favicon/favicon.ico?v=1.12.1" type="image/x-icon" />
<link rel="manifest" href="/dsfr/favicon/manifest.webmanifest?v=1.12.1" crossorigin="use-credentials" />

<link rel="stylesheet" href="/dsfr/utility/icons/icons.min.css" />
<link rel="stylesheet" href="/dsfr/dsfr.min.css" />
<link rel="stylesheet" href="/dsfr/utility/icons/icons.min.css?v=1.12.1" />
<link rel="stylesheet" href="/dsfr/dsfr.min.css?v=1.12.1" />

<!-- Font preload -->
<link
rel="preload"
href="/dsfr/fonts/Marianne-Regular.woff2"
href="/dsfr/fonts/Marianne-Regular.woff2?v=1.12.1"
as="font"
crossorigin="anonymous"
/>
<link rel="preload" href="/dsfr/fonts/Marianne-Medium.woff2" as="font" crossorigin="anonymous" />
<link rel="preload" href="/dsfr/fonts/Marianne-Bold.woff2" as="font" crossorigin="anonymous" />
<link rel="preload" href="/dsfr/fonts/Marianne-Medium.woff2?v=1.12.1" as="font" crossorigin="anonymous" />
<link rel="preload" href="/dsfr/fonts/Marianne-Bold.woff2?v=1.12.1" as="font" crossorigin="anonymous" />
<script>
var matomoURL = '%VITE_TRACKING_URL%'
if (matomoURL) {
var _mtm = window._mtm = window._mtm || [];
var _paq = window._paq = window._paq || [];
_mtm.push({'mtm.startTime': (new Date().getTime()), 'event': 'mtm.Start'});
_paq.push(['HeatmapSessionRecording::disable']);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=matomoURL; s.parentNode.insertBefore(g,s);
})();
}
</script>
</head>


<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
Expand Down
Loading
Loading