Nuget CA certificates error on a docker container of Asp.net core - ssl

I am trying to build a docker container of an asp.net code application and i get errors while trying to retrieve nuget packages
docker build -t my:container .
Sending build context to Docker daemon 9.58 MB
Step 1 : FROM microsoft/dotnet:latest
---> 3693707d4f7f
Step 2 : COPY . /app
---> Using cache
---> 22a461236738
Step 3 : WORKDIR /app
---> Using cache
---> 8bea2af489ad
Step 4 : RUN dotnet restore
---> Running in 5fbfe078c820
log : Restoring packages for /app/project.json...
error: Unable to load the service index for source https://api.nuget.org/v3/index.json.
error: An error occurred while sending the request.
error: Peer certificate cannot be authenticated with given CA certificates
The command 'dotnet restore' returned a non-zero code: 1
The dockerfile i am using is a pretty standard one and based on microsoft/dotnet:latest container.
FROM microsoft/dotnet:latest
COPY . /app
WORKDIR /app
RUN ["dotnet", "restore"]
RUN ["dotnet", "build"]
EXPOSE 9881/tcp
ENV ASPNETCORE_URLS http://*:9881
ENTRYPOINT ["dotnet", "run"]
This used to work a while ago, something seems to have broken but i have no idea what would that be.

The problem was that i was been using an experimental version 1.12.3 of docker.
Everything works great now that i installed the latest official version on windows (still 1.12.3 but not marked as experimental).

Related

How to build container serving Vue SPA using Cloud Native Buildpacks

Currently I'm trying to build container serving VueJS application via Cloud Native Buildpacks.
I already have working Docker file that builds VueJS in production mode and then copy results to nginx image, but I would like to try to use CNB.
So I just have created empty VueJS project for test via vue create vue-tutorial and trying to do with CNB somehting like described there https://cli.vuejs.org/guide/deployment.html#heroku but using CNB.
Does anyone know working recipe how to do that with CNB?
P.S. Currently I'm trying to build that with
pack build spa --path . \  SIGINT(2) ↵  17:22:41
--buildpack gcr.io/paketo-buildpacks/nodejs \
--buildpack gcr.io/paketo-buildpacks/nginx
but getting next error (and I'm not sure that I'm on right way):
===> DETECTING
ERROR: No buildpack groups passed detection.
ERROR: Please check that you are running against the correct path.
ERROR: failed to detect: no buildpacks participating
ERROR: failed to build: executing lifecycle: failed with status code: 100
UPD
My current dockerfile
# build stage
FROM node:lts-alpine as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# production stage
FROM nginx:1.19-alpine as production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
We chatted about this in Slack, but I wanted to capture it here too:
pack build --buildpack heroku/nodejs --buildpack https://cnb-shim.herokuapp.com/v1/heroku-community/static yourimage
This command may do what you want. The static buildpack used in that example is not yet converted to a cloud native buildpack, but the shim may allow you to build a workable artifact. Then run your image with something like docker run -it -e PORT=5000 -p 5000:5000 yourimagename

Error on Debugging docker-compose on VS2019

I have following docker file and docker-compose, it's build and created container images fine through CLI without any problem, however when I try to build it through VS2019 for debugging purpose, it gives an error and I tried to rebuild the project to check where it goes wrong but I could not figure it out. I hope someone point me to the right direction for troubleshooting:-
Docker file:
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
WORKDIR /app
# Copy necessary files and restore as distinct layer
COPY *.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
COPY --from=build-env /app/out .
# Expose ports
EXPOSE 5000/tcp
ENV ASPNETCORE_URLS http://*:5000
HEALTHCHECK --interval=30s --timeout=3s --retries=1 CMD curl --silent --fail http://localhost:5000/hc || exit 1
# Start
ENTRYPOINT ["dotnet", "VehicleManagementAPI.dll"]
Docker-compose file:
services:
vehiclemanagementapi:
image: urgen/vehiclemanagementapi:1.0
build: src/VehiclemanagementAPI
depends_on:
- rabbitmq
- sqlserver
ports:
- "5000"
environment:
- ASPNETCORE_ENVIRONMENT=Production
It is not a particular project has a issue building/compiling docker-compose file rather it happens with all of the projects. As I said it works fine through CLI without any problem, but there has a issue with one particular project, which I wanted to debug in VS2019.
All of the projects build/work fine without dockerize, which means my projects is Okay but issue is with docker-compose or docker file.
Error :
Severity Code Description Project File Line Suppression State
Error CTC1000 (Line: 45, Col: 12, Idx: 954) - (Line: 45, Col: 36, Idx: 978): Exception during deserialization docker-compose C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets 304
I have resolved the problem by making changes in following line in docker-compose file, however I am confused why VS 2019 failed to build the project where it works fine in CLI mode, therefore my understanding is if it has a issue with the docker-compose file structure it would not have been build in CLI mode at the first place:-
build: src/VehicleManagementAPI to build: .
Even the error does not tell anything about the problem, error seems pointless/useless for troubleshooting.

gitlab CI docker stalls after 2min

gitlab CI docker stalls after 2min
slight code change and same bug across different repos. Ci/CD used to work on these repos?
...
Step 4/11 : RUN yarn install
---> Using cache
---> c75197e0dbaa
Step 5/11 : COPY babel.config.js babel.config.js
---> Using cache
---> 482b1ff64322
Step 6/11 : COPY src src
---> d530de056b88
Step 7/11 : RUN mkdir locales
---> Running in f7885ea9a3c3
...
Link to the GL issue
https://gitlab.com/gitlab-com/support-forum/issues/5202
This is a known issue on gitlab. Change dind service as follows. That should fix your problem.
services:
- docker:19.03.5-dind

Deploying AspNet Core to GKE gives connection refused

I am trying to deploy an example Asp.Net Core 3.1 app to GKE, I am building the app in cloud console and it works fine when i am running it from the console with this command "docker run -p 8080:8080 [Image Name]asp-app:v1"
When i deploy it to my Cluster in GKE i cant reach my app althoug i am exposing it with this command: "kubectl expose deployment asp-web --type=LoadBalancer --port 80 --target-port 8080"
I get this error in my webbrowser: "ERR_CONNECTION_REFUSED"
I have managed to deploy another app that where built using Asp.Net Core 2.2 so my settings in GCP should be right.
Does anyone have some experience with this?
Dockerfile:
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /src
COPY ["asp/asp.csproj", "asp/"]
RUN dotnet restore "asp/asp.csproj"
COPY . .
WORKDIR /src/asp
RUN dotnet build "asp.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "asp.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENV ASPNETCORE_URLS http://*:8080
ENTRYPOINT ["dotnet", "asp.dll"]
Figured it out. I had made a new project and added "ENV ASPNETCORE_URLS http://*:8080" to the dockerfile to make it bind to the port while running in the container on GKE.

Deploying Symfony 4 Application to AWS Elasticbeanstalk

I have a working Symfony 4.0.1 application running on PHP 7.1.14 (locally) that I would like to deploy to AWS Elastic Beanstalk using the EB CLI
I have a dist package of the application on my master git branch configured for production (vendor folder removed etc) that I am able to successfully deploy to Heroku. Now I need to deploy to AWS EB.
The AWS EB environment has already been set up (although I dont have access to the console). Some environment details are as follows:
Platform: arn:aws:elasticbeanstalk:us-east-2::platform/Tomcat 8 with Java 8 running on 64bit Amazon Linux/2.7.7
Tier: WebServer-Standard-1.0
At first, I was able to successfully deploy the application, but accessing the URL gave a 404 error for every page.
I did some googling and found a few articles describing the use of .config files. I have added one named 03_main.config with the following contents.
commands:
300-composer-update:
command: "export COMPOSER_HOME=/root && composer.phar self-update -n"
container_commands:
300-run-composer:
command: "composer.phar install --no-dev --optimize-autoloader --prefer-dist --no-interaction"
600-update-cache:
command: "source .ebextensions/bin/update-cache.sh"
700-remove-dev-app:
command: "rm web/app_dev.php"
Deploying with this .config file gives the following deployment failure error:
ERROR: [Instance: i-0c5f61f41d55a18bc] Command failed on instance. Return code: 127 Output: /bin/sh: composer.phar: command not found. command 300-composer-update in .ebextensions/03-main.config failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
I understand the purpose of .config files but do not understand what additional configuration is needed for get this Symfony app running.
I guess you should use the full path to composer like bellow :
100-update-composer:
command: export COMPOSER_HOME=/root && /usr/bin/composer.phar self-update -n