Base solution for your next web application
Open Closed

Angular app build #11806


User avatar
0
kylem created

Hi support team, We are using build-with-ng.ps1 to build our angular application and I can see the power shell generates a Dockerfile for each environment based on parameter we are passing to it.

# aspnet-core/build/outputs/aws/Dockerfile

FROM nginx
COPY . /usr/share/nginx/html
COPY nginx.conf /etc/nginx/

our process currently is:

  1. I use that Dockerfile to build a docker container and push it to dockerhub
  2. On run time when deploying the angular app to the EKS (kubernetes cluster) I mount the right app-config.json file
appconfig.staging.json: |
    {
      "remoteServiceBaseUrl": "{{ .Values.api_url }}",
      "appBaseUrl": "{{ .Values.console_url }}",
      "localeMappings": {
        "angular": [
          {
            "from": "pt-BR",
            "to": "pt"
          },
          {
            "from": "zh-CN",
            "to": "zh"
          },
          {
            "from": "he-IL",
            "to": "he"
          },
          {
            "from": "es-MX",
            "to": "es"
          },
          {
            "from": "vi",
            "to": "en"
          }
        ],
        "luxon": [
          {
            "from": "es-MX",
            "to": "es"
          },
          {
            "from": "zh-Hans",
            "to": "zh-cn"
          },
          {
            "from": "vi",
            "to": "en-gb"
          }
        ],
        "recaptcha": [
          {
            "from": "zh-Hans",
            "to": "zh-cn"
          },
          {
            "from": "es-MX",
            "to": "es"
          }
        ]
      },
      "helpdeskUrl" : "/app/main/helpdesk-not-available",
      "contactUsUrl" : "https://www.denvrdata.com/contact",
      "privacyPolicyUrl" : "https://www.denvrdata.com/privacy",
      "termsOfServiceUrl" : "https://www.denvrdata.com/terms-of-service",
      "documentationUrl" : "https://support.denvrdata.com/portal/en/kb/denvr-cloud",
      "helpdeskTicketsUrl": "/app/main/helpdesk-not-available",
      "defaultClusterUrl": "https://msc1.cloud.denvrdata.com",
      "whatIsNewUrl": "https://support.denvrdata.com/portal/en/kb/articles/whats-new",
      "termsAndConditionsUrl": "https://www.denvrdata.com/terms-of-use-embedded",
      "trialTermsAndConditionsUrl": "https://www.denvrdata.com/test-drive-terms-of-use-embedded"
    }

also noticed there is an env variable difference between environments

- name: ASPNETCORE_ENVIRONMENT
  value: "Staging"
- name: ASPNETCORE_URLS
  value: "http://+:80"

Technically what I am trying to do is I want to build only one docker container image for each version we build and use that across all environemtns currently we have dev and prod I want to pass appconfig.json and env variables to reuse the same built image,

  1. is this something you are encouraging us not to do?
  2. do you have any suggestion for us?
  3. is this going to be breaking change since ng build --configuration dev,staging,prod adds something else that we are not aware of?
  4. can we simplify our build-with-ng.ps1 to only one generic environment neutral build and pass args as explained above?

#kubernetes #EKS #githubactions #docekrfile #dockerbuild #dockerhub #configmap

great thanks,
Moe - [email protected] - 1(416)824-1670


5 Answer(s)
  • User Avatar
    1
    ismcagdas created
    Support Team

    Hi,

    appconfig file is loaded depending on the provided environment here https://github.com/aspnetzero/aspnet-zero-core/blob/dev/angular/src/AppPreBootstrap.ts#L101. In your scenario, I think you need to change this function to handle your requirement.

  • User Avatar
    0
    kylem created

    Hi, the link provided is not accessible and returns 404,

    I looked into that files locally and am not able to relate to my question would you please provide more details?

    thanks, Moe

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    To see the content of that link, you can add your GitHub user on https://aspnetzero.com/LicenseManagement or you can send an email to [email protected]

  • User Avatar
    0
    kylem created

    hi, I already have that file on our own instance of framework and can see the content on our end , your reply about you need to change this function to handle your requirement. was not helpful since I am not sure why we need to modify an internal file on framework to support env agnostic deployments.

  • User Avatar
    1
    ismcagdas created
    Support Team

    Hi @kylem

    Envorinment specific deployment is a well known approach for Angular apps and it is the default behaviour provided by Angular itself. Since your requirement is not supported out of the box, you need to implement it yourself.