diff --git a/apps/kyb-app/Dockerfile b/apps/kyb-app/Dockerfile index b7e795156f..032a90c9f5 100644 --- a/apps/kyb-app/Dockerfile +++ b/apps/kyb-app/Dockerfile @@ -9,20 +9,29 @@ RUN npm install --legacy-peer-deps COPY . . RUN mv /app/.env.example /app/.env + RUN npm run build -ENV PATH="$PATH:./node_modules/.bin" +ENV PATH="$PATH:/app/node_modules/.bin" EXPOSE 5201 -CMD ["npm","run","dev", "--host"] +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/kyb-app/entrypoint.sh b/apps/kyb-app/entrypoint.sh new file mode 100644 index 0000000000..fc90b86708 --- /dev/null +++ b/apps/kyb-app/entrypoint.sh @@ -0,0 +1,46 @@ +#!/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_ENVIRONMENT_NAME" ]] +then + VITE_ENVIRONMENT_NAME=local +fi + + +if [[ -z "$VITE_DEFAULT_EXAMPLE_TOKEN" ]] +then + VITE_DEFAULT_EXAMPLE_TOKEN=12345678-1234-1234-1234-123456789012 +fi + +if [[ -z "$VITE_SENTRY_AUTH_TOKEN" ]] +then + VITE_SENTRY_AUTH_TOKEN="" +fi + +if [[ -z "$VITE_SENTRY_DSN" ]] +then + VITE_SENTRY_DSN="" +fi + +cat << EOF > /usr/share/nginx/html/config.js +globalThis.env = { + VITE_API_URL: "$VITE_DOMAIN/api/v1/", + VITE_API_KEY: "$VITE_API_KEY", + VITE_ENVIRONMENT_NAME: "$VITE_ENVIRONMENT_NAME", + VITE_DEFAULT_EXAMPLE_TOKEN: "$VITE_DEFAULT_EXAMPLE_TOKEN", + VITE_SENTRY_AUTH_TOKEN: "$VITE_SENTRY_AUTH_TOKEN", + VITE_SENTRY_DSN: "$VITE_SENTRY_DSN", +} +EOF + +# Handle CMD command +exec "$@" diff --git a/apps/kyb-app/global.d.ts b/apps/kyb-app/global.d.ts new file mode 100644 index 0000000000..3e423828a7 --- /dev/null +++ b/apps/kyb-app/global.d.ts @@ -0,0 +1,3 @@ +declare global { + export var env: { [key: string]: any }; +} diff --git a/apps/kyb-app/index.html b/apps/kyb-app/index.html index ce258bdc02..d9ecbcf049 100644 --- a/apps/kyb-app/index.html +++ b/apps/kyb-app/index.html @@ -7,6 +7,7 @@