diff --git a/apps/backoffice-v2/Dockerfile b/apps/backoffice-v2/Dockerfile index 7266207d0f..1249f14fdf 100644 --- a/apps/backoffice-v2/Dockerfile +++ b/apps/backoffice-v2/Dockerfile @@ -22,10 +22,18 @@ CMD ["npm", "run", "dev", "--host"] FROM nginx:stable-alpine as prod +WORKDIR /app + COPY --from=dev /app/dist /usr/share/nginx/html +COPY --from=dev /app/entrypoint.sh /app/entrypoint.sh + COPY example.nginx.conf /etc/nginx/conf.d/default.conf +RUN chmod a+x /app/entrypoint.sh; + EXPOSE 80 +ENTRYPOINT [ "/app/entrypoint.sh" ] + CMD ["nginx", "-g", "daemon off;"] diff --git a/apps/backoffice-v2/entrypoint.sh b/apps/backoffice-v2/entrypoint.sh new file mode 100644 index 0000000000..e3b7ce7ec3 --- /dev/null +++ b/apps/backoffice-v2/entrypoint.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env sh + +if [[ -z "$VITE_DOMAIN" ]] +then + VITE_DOMAIN="http://localhost:3000" +fi + +if [[ -z "$VITE_API_KEY" ]] +then + VITE_API_KEY="secret" +fi + +if [[ -z "$VITE_AUTH_ENABLED" ]] +then + VITE_AUTH_ENABLED=true +fi + + +if [[ -z "$VITE_MOCK_SERVER" ]] +then + VITE_MOCK_SERVER=false +fi + +if [[ -z "$VITE_POLLING_INTERVAL" ]] +then + VITE_POLLING_INTERVAL=10 +fi + +if [[ -z "$VITE_ASSIGNMENT_POLLING_INTERVAL" ]] +then + VITE_ASSIGNMENT_POLLING_INTERVAL=5 +fi + +if [[ -z "$VITE_FETCH_SIGNED_URL" ]] +then + VITE_FETCH_SIGNED_URL=false +fi + +cat << EOF > /usr/share/nginx/html/config.js +globalThis.env = { + VITE_API_URL: "$VITE_DOMAIN/api/v1/internal", + VITE_API_KEY: "$VITE_API_KEY", + VITE_AUTH_ENABLED: "$VITE_AUTH_ENABLED", + VITE_MOCK_SERVER: "$VITE_MOCK_SERVER", + VITE_POLLING_INTERVAL: "$VITE_POLLING_INTERVAL", + VITE_ASSIGNMENT_POLLING_INTERVAL: "$VITE_ASSIGNMENT_POLLING_INTERVAL", + VITE_FETCH_SIGNED_URL: "$VITE_FETCH_SIGNED_URL", + VITE_ENVIRONMENT_NAME: "local", + MODE: "production" +} +EOF + +# Handle CMD command +exec "$@" diff --git a/apps/backoffice-v2/global.d.ts b/apps/backoffice-v2/global.d.ts new file mode 100644 index 0000000000..3e423828a7 --- /dev/null +++ b/apps/backoffice-v2/global.d.ts @@ -0,0 +1,3 @@ +declare global { + export var env: { [key: string]: any }; +} diff --git a/apps/backoffice-v2/index.html b/apps/backoffice-v2/index.html index 44029b0e6c..5ab09a4edc 100644 --- a/apps/backoffice-v2/index.html +++ b/apps/backoffice-v2/index.html @@ -8,6 +8,7 @@