Skip to content

Commit

Permalink
Ajout dockerfile déploiement
Browse files Browse the repository at this point in the history
  • Loading branch information
cdebarros committed Dec 5, 2023
1 parent a8041e5 commit 7a6beee
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: .
file: tools/docker/Dockerfile.apps
file: tools/docker/Dockerfile
build-args: APP_NAME=datahub
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
Expand Down
26 changes: 26 additions & 0 deletions tools/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This dockerfile should work for all traditional apps,
# i.e. it only sets up a nginx server with the app dist folder

FROM nginx:1.24-alpine

ARG APP_NAME="search"
ENV APP_NAME=${APP_NAME}
ENV GN4_API_URL ""
ENV PROXY_PATH ""
ENV CONFIG_DIRECTORY_OVERRIDE ""
ENV ASSETS_DIRECTORY_OVERRIDE ""
ENV CUSTOM_SCRIPTS_DIRECTORY ""

COPY dist/apps/${APP_NAME} /usr/share/nginx/html/${APP_NAME}
COPY tools/docker/docker-entrypoint.sh /

# copy Web Components HTML embedder as a bonus
COPY tools/webcomponent/wc-embedder.html /usr/share/nginx/html/${APP_NAME}

# copy default NGINX conf & put the app name in it
COPY tools/docker/nginx.ign.conf /etc/nginx/conf.d/default.conf
RUN sed -i "s/APP_NAME/${APP_NAME}/" /etc/nginx/conf.d/default.conf

EXPOSE 80

ENTRYPOINT ["sh", "/docker-entrypoint.sh", "nginx", "-g", "daemon off;"]
30 changes: 30 additions & 0 deletions tools/docker/nginx.ign.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
server {
listen 80;
listen [::]:80;
server_name localhost;

root /usr/share/nginx/html/datahub;

server_tokens off;

location ~ /index.html|.*\.toml|.*\.json$ {
expires -1;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
}

location ~ .*\.css$|.*\.js$ {
add_header Cache-Control 'max-age=86400'; # 24h
}

location / {
try_files $uri$args $uri$args/ /index.html;

add_header Cache-Control 'max-age=86400'; # 24h
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}

0 comments on commit 7a6beee

Please sign in to comment.