Additional ASP.NET Core Web APIs are not getting published to Docker production

I need some help regarding publishing the ASP.NET Core Web APIs to the gitlab docker production environment. I have inherited the code from another team, and the current APIs are working fine on production, even if I make changes on them and re-publish it again.

However, when I add another controller, it works well in the local environment, but fails to load in the production environment.

I have set the following in launchsettings.json:

  "environmentVariables": {
      "ASPNETCORE_ENVIRONMENT": "Production"
  }

I added a default out-of-the-box controller and it works locally, but I get an http 404 error in the production environment.

using Microsoft.AspNetCore.Mvc;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace testweb.default
{
    [Route("api/[controller]")]
    [ApiController]
    public class ValuesController : ControllerBase
    {
        // GET: api/<ValuesController>
        [HttpGet]
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "value2" };
        }

        // GET api/<ValuesController>/5
        [HttpGet("{id}")]
        public string Get(int id)
        {
            return "value";
        }

        // POST api/<ValuesController>
        [HttpPost]
        public void Post([FromBody] string value)
        {
        }

        // PUT api/<ValuesController>/5
        [HttpPut("{id}")]
        public void Put(int id, [FromBody] string value)
        {
        }

        // DELETE api/<ValuesController>/5
        [HttpDelete("{id}")]
        public void Delete(int id)
        {
        }
    }
}

Here is my .gitlab-ci.yml file

variables:
  DOCKER_IMAGE_PRODUCTION : $CI_REGISTRY_IMAGE 
  DOCKER_IMAGE_TEST       : $CI_REGISTRY_IMAGE 
  DOCKER_IMAGE_DEV        : $CI_REGISTRY_IMAGE

stages :
  - push_registry_dev
  - update_manifests_dev
  - push_registry_test
  - update_manifests_test
  - push_registry_uat
  - update_manifests_uat

  
build_image_dev:
  stage: push_registry_dev
  image : mcr.microsoft.com/dotnet/sdk:8.0
  services:
    - docker:24.0.6-dind
  variables: 
    DOCKER_HOST: tcp://docker:2375/
    DOCKER_DRIVER: overlay2
    DOCKER_TLS_CERTDIR: ""
  before_script:
    - cat /etc/os-release
    - curl -sSL https://get.docker.com/ | sh
    - echo -n $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
    - export PATH="$PATH:/root/.dotnet/tools"
    - dotnet tool install --global dotnet-ef
  script:
    # - cat .env.development > .env
    # - docker build  -f dev.Dockerfile --tag $DOCKER_IMAGE_TEST:$CI_COMMIT_SHORT_SHA-dev .
    #- dotnet ef database update --project TestProject.Infrastructure/ --startup-project TestProject.Web/ --connection "Server=***.***.***.***;Initial Catalog=db;User Id=sa;Password=*******;TrustServerCertificate=true"
    - cd ./TestProject.Web
    - dotnet publish --os linux --arch x64 -p:PublishProfile=DefaultContainer -p:ContainerImageName=test-backend
    - docker tag test-backend $DOCKER_IMAGE_TEST:$CI_COMMIT_SHORT_SHA-dev
    - docker push $DOCKER_IMAGE_TEST:$CI_COMMIT_SHORT_SHA-dev

  only:
    - develop
    - main
    - prod
  tags :
    - gitlab-org-docker
 


update_manifest_dev:
  stage: update_manifests_dev
  variables:
    GIT_STRATEGY: none
  retry: 2
  image: docker:24.0.6
  services:
    - docker:24.0.6-dind
  script:
    # Add SSH key to root
    - mkdir -p /root/.ssh
    - cat "${GIT_SSH}" > /root/.ssh/id_rsa
    - ssh-keyscan -H gitlab.com > /root/.ssh/known_hosts
    - chmod 400 /root/.ssh/id_rsa
    - apk add --no-cache git 
    - export GIT_SSH_COMMAND="ssh -i ~/.ssh/id_rsa"
    - git config --global user.name "username"
    - git config --global user.email "[email protected]"
    - git clone --single-branch --branch main [email protected]:company/k8s-manifests.git
    - cd k8s-manifests/test/dev/api
    - export REPO=$DOCKER_IMAGE_DEV:$CI_COMMIT_SHORT_SHA-dev
    - chmod -R 777 ${PWD}
    - docker run --rm -v ${PWD}:/workdir -e REPO=$REPO mikefarah/yq:4.12.2  e '.spec.template.spec.containers[0].image=env(REPO)' --inplace deployment.yml
    - git commit -am "New version updated ${CI_COMMIT_SHORT_SHA}-dev" && git push origin main
  tags: 
    - gitlab-org-docker
  needs: ["build_image_dev"]
  only:
    refs:
    - develop
    - main
    - prod

Is there anything else I need to change in the code? I am not that conversant with docker technologies.

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật