Build docker image with azure pipelines still 401 (Unauthorized) - image

I'm trying to build a linux docker image via azure pipelines.
Main problem is with restore from private feed.
I read many article how to do that but still getting same error
"error : Response status code does not indicate success: 401 (Unauthorized)."
So how its looks my files
Dockerfile:
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine AS build
WORKDIR /src
COPY MyAppService/MyAppService.csproj MyAppService/
COPY NuGet.Config .
ARG NUGET_PAT
ARG AZURE_FEED
ENV NUGET_CREDENTIALPROVIDER_SESSIONTOKENCACHE_ENABLED true
ENV VSS_NUGET_EXTERNAL_FEED_ENDPOINTS "{\"endpointCredentials\": [{\"endpoint\":\"${AZURE_FEED}\", \"username\":\"docker\", \"password\":\"${NUGET_PAT}\"}]}"
RUN wget -O - https://aka.ms/install-artifacts-credprovider.sh
# check env are ok
RUN printenv
RUN dotnet restore --configfile NuGet.Config "MyAppService/MyAppService.csproj"
COPY MyAppService/. MyAppService/
RUN dotnet build "MyAppService/MyAppService.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "MyAppService/MyAppService.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyAppService.dll"]
NuGet.Config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="mytestorganization" value="https://pkgs.dev.azure.com/mytestorganization/_packaging/mytestorganization/nuget/v3/index.json" />
</packageSources>
</configuration>
And log file from azure pipeline when trying build a image:
2021-05-20T11:36:22.7867465Z ##[section]Starting: build
2021-05-20T11:36:22.7875209Z ==============================================================================
2021-05-20T11:36:22.7875497Z Task : Docker
2021-05-20T11:36:22.7875990Z Description : Build or push Docker images, login or logout, start or stop containers, or run a Docker command
2021-05-20T11:36:22.7876270Z Version : 2.185.0
2021-05-20T11:36:22.7876466Z Author : Microsoft Corporation
2021-05-20T11:36:22.7876713Z Help : https://aka.ms/azpipes-docker-tsg
2021-05-20T11:36:22.7876983Z ==============================================================================
2021-05-20T11:36:27.0474614Z [command]/usr/bin/docker build -f /home/vsts/work/1/s/Dockerfile --label com.azure.dev.image.system.teamfoundationcollectionuri=https://dev.azure.com/mytestorganization/ --label com.azure.dev.image.system.teamproject=TestProject --label com.azure.dev.image.build.repository.name=MyAppService --label com.azure.dev.image.build.sourceversion=63bc9999e1005c9aec016231dcc0f15cf9ec83da --label com.azure.dev.image.build.repository.uri=https://mytestorganization#dev.azure.com/mytestorganization/TestProject/_git/MyAppService --label com.azure.dev.image.build.sourcebranchname=testbranch --label com.azure.dev.image.build.definitionname=TestProject-CI --label com.azure.dev.image.build.buildnumber=144 --label com.azure.dev.image.build.builduri=vstfs:///Build/Build/144 --build-arg AZURE_FEED=http://pkgs.dev.azure.com/mytestorganization/_packaging/mytestorganization/nuget/v3/index.json --build-arg NUGET_PAT=wz2ilhvt2urpzqlqlldd2f2hl6do77jkmreydrpmskwco3fc7sva /home/vsts/work/1/s
2021-05-20T11:36:30.9509673Z Sending build context to Docker daemon 203.3kB
2021-05-20T11:36:30.9510485Z
2021-05-20T11:36:31.0442686Z Step 1/32 : FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine AS base
2021-05-20T11:36:31.2889870Z 3.1-alpine: Pulling from dotnet/core/aspnet
2021-05-20T11:36:31.2907305Z 540db60ca938: Already exists
2021-05-20T11:36:31.3239989Z 9c2872b91813: Pulling fs layer
2021-05-20T11:36:31.3240441Z 8628df474c5d: Pulling fs layer
2021-05-20T11:36:31.3240760Z b54f4c6d2c91: Pulling fs layer
2021-05-20T11:36:31.3981063Z 9c2872b91813: Verifying Checksum
2021-05-20T11:36:31.3981449Z 9c2872b91813: Download complete
2021-05-20T11:36:31.4335354Z b54f4c6d2c91: Verifying Checksum
2021-05-20T11:36:31.4339309Z b54f4c6d2c91: Download complete
2021-05-20T11:36:31.6869948Z 8628df474c5d: Verifying Checksum
2021-05-20T11:36:31.6870377Z 8628df474c5d: Download complete
2021-05-20T11:36:32.0023325Z 9c2872b91813: Pull complete
2021-05-20T11:36:33.1851800Z 8628df474c5d: Pull complete
2021-05-20T11:36:33.5201247Z b54f4c6d2c91: Pull complete
2021-05-20T11:36:33.5262719Z Digest: sha256:97c4986a2f9c8d2bc40443eb0baac59f35c43c267fc59ecc626b449701152df9
2021-05-20T11:36:33.5294596Z Status: Downloaded newer image for mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine
2021-05-20T11:36:33.5314476Z ---> f039e2539446
2021-05-20T11:36:33.5314887Z Step 2/32 : WORKDIR /app
2021-05-20T11:36:33.5511196Z ---> Running in 935279916ded
2021-05-20T11:36:34.0084321Z Removing intermediate container 935279916ded
2021-05-20T11:36:34.0085263Z ---> acbf5abca7a7
2021-05-20T11:36:34.0085629Z Step 3/32 : EXPOSE 80
2021-05-20T11:36:34.0265101Z ---> Running in f7fa1a4dd856
2021-05-20T11:36:35.0147354Z Removing intermediate container f7fa1a4dd856
2021-05-20T11:36:35.0148907Z ---> ac616daad00f
2021-05-20T11:36:35.0152411Z Step 4/32 : EXPOSE 443
2021-05-20T11:36:35.0322549Z ---> Running in b3850b437c79
2021-05-20T11:36:36.0098236Z Removing intermediate container b3850b437c79
2021-05-20T11:36:36.0099219Z ---> cb4e679d3e31
2021-05-20T11:36:36.0099779Z Step 5/32 : FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine AS build
2021-05-20T11:36:36.5177448Z 3.1-alpine: Pulling from dotnet/core/sdk
2021-05-20T11:36:36.5178298Z 540db60ca938: Already exists
2021-05-20T11:36:36.5178735Z 9c2872b91813: Already exists
2021-05-20T11:36:36.5179120Z 8628df474c5d: Already exists
2021-05-20T11:36:36.5179575Z b54f4c6d2c91: Already exists
2021-05-20T11:36:36.5180041Z c1b534528ba7: Pulling fs layer
2021-05-20T11:36:36.5180819Z db0b8f999807: Pulling fs layer
2021-05-20T11:36:36.5181265Z 668300e8efd0: Pulling fs layer
2021-05-20T11:36:36.5181785Z 668300e8efd0: Verifying Checksum
2021-05-20T11:36:36.5182381Z 668300e8efd0: Download complete
2021-05-20T11:36:36.5182681Z c1b534528ba7: Verifying Checksum
2021-05-20T11:36:36.5182991Z c1b534528ba7: Download complete
2021-05-20T11:36:36.9095207Z db0b8f999807: Verifying Checksum
2021-05-20T11:36:36.9095902Z db0b8f999807: Download complete
2021-05-20T11:36:37.5777094Z c1b534528ba7: Pull complete
2021-05-20T11:36:41.4075714Z db0b8f999807: Pull complete
2021-05-20T11:36:42.0343103Z 668300e8efd0: Pull complete
2021-05-20T11:36:42.0398152Z Digest: sha256:468b7f80a5ddad15081eddf072ea67d2d003e82c7937392bf927692b134633f5
2021-05-20T11:36:42.0430106Z Status: Downloaded newer image for mcr.microsoft.com/dotnet/core/sdk:3.1-alpine
2021-05-20T11:36:42.0445206Z ---> a08ae6c8a2aa
2021-05-20T11:36:42.0445502Z Step 6/32 : WORKDIR /src
2021-05-20T11:36:42.0748860Z ---> Running in 6dae098fc8ed
2021-05-20T11:36:43.0138598Z Removing intermediate container 6dae098fc8ed
2021-05-20T11:36:43.0139677Z ---> e151bdc4004f
2021-05-20T11:36:43.0140964Z Step 7/32 : COPY MyAppService/MyAppService.csproj MyAppService/
2021-05-20T11:36:44.0159585Z ---> 30c607bb8a6e
2021-05-20T11:36:44.0159936Z Step 8/32 : COPY NuGet.Config .
2021-05-20T11:36:45.0146826Z ---> 21b4b5d1f04c
2021-05-20T11:36:45.0147184Z Step 9/32 : ARG NUGET_PAT
2021-05-20T11:36:45.0460635Z ---> Running in 88d83e60cf3a
2021-05-20T11:36:46.0172444Z Removing intermediate container 88d83e60cf3a
2021-05-20T11:36:46.0173490Z ---> 58d9dde29d1d
2021-05-20T11:36:46.0173821Z Step 10/32 : ARG AZURE_FEED
2021-05-20T11:36:46.0360209Z ---> Running in f10912b5009e
2021-05-20T11:36:47.0134976Z Removing intermediate container f10912b5009e
2021-05-20T11:36:47.0135971Z ---> e792f313ec6c
2021-05-20T11:36:47.0136338Z Step 11/32 : ENV NUGET_CREDENTIALPROVIDER_SESSIONTOKENCACHE_ENABLED true
2021-05-20T11:36:47.0340003Z ---> Running in dc9e064c144a
2021-05-20T11:36:48.0165125Z Removing intermediate container dc9e064c144a
2021-05-20T11:36:48.0166236Z ---> 2cb8ce18a003
2021-05-20T11:36:48.0166823Z Step 12/32 : ENV VSS_NUGET_EXTERNAL_FEED_ENDPOINTS "{\"endpointCredentials\": [{\"endpoint\":\"${AZURE_FEED}\", \"username\":\"docker\", \"password\":\"${NUGET_PAT}\"}]}"
2021-05-20T11:36:48.0346391Z ---> Running in 06e748e76592
2021-05-20T11:36:49.0167180Z Removing intermediate container 06e748e76592
2021-05-20T11:36:49.0168216Z ---> 21dff5c2a393
2021-05-20T11:36:49.0168806Z Step 13/32 : RUN wget -O - https://aka.ms/install-artifacts-credprovider.sh
2021-05-20T11:36:49.0331863Z ---> Running in 653d535fd87e
2021-05-20T11:36:50.5360687Z [91mConnecting to aka.ms (104.67.209.176:443)
2021-05-20T11:36:50.9255227Z [0m[91mConnecting to raw.githubusercontent.com (185.199.109.133:443)
2021-05-20T11:36:51.0266615Z [0m[91mwriting to stdout
2021-05-20T11:36:51.0269224Z [0m#!/usr/bin/env bash
2021-05-20T11:36:51.0269620Z # DESCRIPTION: A simple shell script designed to fetch the latest version
2021-05-20T11:36:51.0270020Z # of the artifacts credential provider plugin for dotnet and
2021-05-20T11:36:51.0270333Z # install it into $HOME/.nuget/plugins.
2021-05-20T11:36:51.0270979Z # SEE: https://github.com/Microsoft/artifacts-credprovider/blob/master/README.md
2021-05-20T11:36:51.0271177Z
2021-05-20T11:36:51.0271529Z REPO="Microsoft/artifacts-credprovider"
2021-05-20T11:36:51.0271833Z FILE="Microsoft.NuGet.CredentialProvider.tar.gz"
2021-05-20T11:36:51.0272080Z VERSION="latest"
2021-05-20T11:36:51.0272612Z # URL pattern documented at https://help.github.com/en/articles/linking-to-releases as of 2019-03-29
2021-05-20T11:36:51.0273028Z URI="https://github.com/$REPO/releases/$VERSION/download/$FILE"
2021-05-20T11:36:51.0273327Z NUGET_PLUGIN_DIR="$HOME/.nuget/plugins"
2021-05-20T11:36:51.0273475Z
2021-05-20T11:36:51.0273677Z # Ensure plugin directory exists
2021-05-20T11:36:51.0274069Z if [ ! -d "${NUGET_PLUGIN_DIR}" ]; then
2021-05-20T11:36:51.0274767Z echo "INFO: Creating the nuget plugin directory (i.e. ${NUGET_PLUGIN_DIR}). "
2021-05-20T11:36:51.0275283Z if ! mkdir -p "${NUGET_PLUGIN_DIR}"; then
2021-05-20T11:36:51.0275655Z echo "ERROR: Unable to create nuget plugins directory (i.e. ${NUGET_PLUGIN_DIR})."
2021-05-20T11:36:51.0275955Z exit 1
2021-05-20T11:36:51.0276136Z fi
2021-05-20T11:36:51.0276320Z fi
2021-05-20T11:36:51.0276403Z
2021-05-20T11:36:51.0276599Z echo "Downloading from $URI"
2021-05-20T11:36:51.0276893Z # Extract netcore from the .tar.gz into the plugin directory
2021-05-20T11:36:51.0277180Z
2021-05-20T11:36:51.0277502Z #Fetch the file
2021-05-20T11:36:51.0278259Z curl -H "Accept: application/octet-stream" \
2021-05-20T11:36:51.0278673Z -s \
2021-05-20T11:36:51.0279032Z -S \
2021-05-20T11:36:51.0279377Z -L \
2021-05-20T11:36:51.0279833Z "$URI" | tar xz -C "$HOME/.nuget/" "plugins/netcore"
2021-05-20T11:36:51.0280016Z
2021-05-20T11:36:51.0280338Z echo "INFO: credential provider netcore plugin extracted to $HOME/.nuget/"
2021-05-20T11:36:51.0291723Z [91m- 100% |********************************| 1213[0m[91m 0:00:00 ETA
2021-05-20T11:36:51.0292150Z written to stdout
2021-05-20T11:36:52.0145556Z [0mRemoving intermediate container 653d535fd87e
2021-05-20T11:36:52.0146179Z ---> 90962e0fe2f3
2021-05-20T11:36:52.0146481Z Step 14/32 : RUN printenv
2021-05-20T11:36:52.0341626Z ---> Running in de688137dee7
2021-05-20T11:36:52.3685737Z DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
2021-05-20T11:36:52.3686185Z NUGET_CREDENTIALPROVIDER_SESSIONTOKENCACHE_ENABLED=true
2021-05-20T11:36:52.3686469Z HOSTNAME=de688137dee7
2021-05-20T11:36:52.3686745Z DOTNET_USE_POLLING_FILE_WATCHER=true
2021-05-20T11:36:52.3686993Z SHLVL=1
2021-05-20T11:36:52.3687187Z HOME=/root
2021-05-20T11:36:52.3687432Z DOTNET_RUNNING_IN_CONTAINER=true
2021-05-20T11:36:52.3687794Z AZURE_FEED=http://pkgs.dev.azure.com/mytestorganization/_packaging/mytestorganization/nuget/v3/index.json
2021-05-20T11:36:52.3688201Z NUGET_PAT=wz2ilhvt2urpzqlqlldd2f2hl6do77jkmreydrpmskwco3fc7sva
2021-05-20T11:36:52.3689296Z POWERSHELL_DISTRIBUTION_CHANNEL=PSDocker-DotnetCoreSDK-Alpine-3.13
2021-05-20T11:36:52.3689701Z PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
2021-05-20T11:36:52.3690173Z LANG=en_US.UTF-8
2021-05-20T11:36:52.3690539Z LC_ALL=en_US.UTF-8
2021-05-20T11:36:52.3690774Z ASPNETCORE_URLS=
2021-05-20T11:36:52.3691003Z PWD=/src
2021-05-20T11:36:52.3691618Z VSS_NUGET_EXTERNAL_FEED_ENDPOINTS={"endpointCredentials": [{"endpoint":"http://pkgs.dev.azure.com/mytestorganization/_packaging/mytestorganization/nuget/v3/index.json", "username":"docker", "password":"wz2ilhvt4ghjrpzqlqllxsda2hl6do77jkmreyvotsaskwco3fc7sva"}]}
2021-05-20T11:36:52.3692283Z NUGET_XMLDOC_MODE=skip
2021-05-20T11:36:53.0269908Z Removing intermediate container de688137dee7
2021-05-20T11:36:53.0277361Z ---> 47c3745c86a9
2021-05-20T11:36:53.0278468Z Step 15/32 : RUN dotnet restore --configfile NuGet.Config "MyAppService/MyAppService.csproj"
2021-05-20T11:36:53.0300480Z ---> Running in 7cb2aad61823
2021-05-20T11:36:54.4782539Z Determining projects to restore...
2021-05-20T11:36:55.5458935Z /usr/share/dotnet/sdk/3.1.409/NuGet.targets(128,5): error : Unable to load the service index for source https://pkgs.dev.azure.com/mytestorganization/_packaging/mytestorganization/nuget/v3/index.json. [/src/MyAppService/MyAppService.csproj]
2021-05-20T11:36:55.5459838Z /usr/share/dotnet/sdk/3.1.409/NuGet.targets(128,5): error : Response status code does not indicate success: 401 (Unauthorized). [/src/MyAppService/MyAppService.csproj]
2021-05-20T11:36:55.7208436Z The command '/bin/sh -c dotnet restore --configfile NuGet.Config "MyAppService/MyAppService.csproj"' returned a non-zero code: 1
2021-05-20T11:36:55.7348351Z ##[error]The command '/bin/sh -c dotnet restore --configfile NuGet.Config "MyAppService/MyAppService.csproj"' returned a non-zero code: 1
2021-05-20T11:36:55.7359274Z ##[error]The process '/usr/bin/docker' failed with exit code 1
2021-05-20T11:36:55.7376406Z ##[section]Finishing: build
I tried many thinks like give full acces token. So what im doing wrong?

Try to add verification information to your package source. Use packageSourceCredentials under custom nuget.config file:
Modify your nuget.config as:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="mytestorganization" value="https://pkgs.dev.azure.com/mytestorganization/_packaging/mytestorganization/nuget/v3/index.json" />
</packageSources>
<packageSourceCredentials>
<mytestorganization>
<add key="Username" value="xxxx" />
<add key="Password" value="xxxx" />
</mytestorganization>
</packageSourceCredentials>
</configuration>

Related

monitoring esxi using prometheus : getting error undefined: debug.ReadBuildInfo

i am trying monitor esxi via prometheus to grafana using https://github.com/devinotelecom/prometheus-vmware-exporter
when i am running
[root#admin01 prometheus-vmware-exporter]# docker build -t prometheus-vmware-exporter .
Sending build context to Docker daemon 157.7kB
Step 1/9 : FROM golang:1.11 as builder
---> 43a154fee764
Step 2/9 : WORKDIR /src/github.com/devinotelecom/prometheus-vmware-exporter
---> Using cache
---> 6b2aad4c7a43
Step 3/9 : COPY ./ /src/github.com/devinotelecom/prometheus-vmware-exporter
---> Using cache
---> 2f5f1b155f7f
Step 4/9 : RUN go get -d -v
---> Using cache
---> a48d35b3d5e2
Step 5/9 : RUN CGO_ENABLED=0 GOOS=linux go build
---> Running in 86199cee4fcb
# github.com/prometheus/client_golang/prometheus
/go/src/github.com/prometheus/client_golang/prometheus/build_info_collector.go:24:15: undefined: debug.ReadBuildInfo
The command '/bin/sh -c CGO_ENABLED=0 GOOS=linux go build' returned a non-zero code: 2
[root#admin01 prometheus-vmware-exporter]#
Thanks for your help in Advanced
The minimal golang version in prometheus is 1.15, but in the Dockerfile it says 1.11
source : https://github.com/prometheus/client_golang/blob/main/go.mod
Try changing golang:1.11 to golang:1.15++ in Dockerfile

how to enlarge docker container size?

I need to create a big docker image with the following steps:
Create Dockerfile with the following info:
FROM mcr.microsoft.com/dotnet/core/sdk:3.1.202-bionic as build
ARG BUILDCONFIG=RELEASE
ARG VERSION=1.0.0
WORKDIR .
COPY . /build/
COPY Model/Model.sln /build/Model/
RUN dotnet build ./build/Model/Model.sln
RUN dotnet restore ./build/Model/Model.sln
WORKDIR /build/Model
RUN dotnet publish Model.sln -c $BUILDCONFIG -o out /p:Version=$VERSION
Build docker image with following command
$ docker build -t modelwithpr .
Sending build context to Docker daemon 27.39GB
Step 1/10 : FROM mcr.microsoft.com/dotnet/core/sdk:3.1.202-bionic as build
3.1.202-bionic: Pulling from dotnet/core/sdk
23884877105a: Pull complete
bc38caa0f5b9: Pull complete
2910811b6c42: Pull complete
36505266dcc6: Pull complete
21e3523d71cd: Pull complete
3c423fdfc300: Pull complete
3c953506ccad: Pull complete
3b8b572de54f: Pull complete
8f2eb870f86d: Pull complete
e52b20b76b9c: Pull complete
Digest: sha256:9ee35c3d8395a15b21cc2eca5d66c8e7df62254c12ddb1249731c568458de124
Status: Downloaded newer image for mcr.microsoft.com/dotnet/core/sdk:3.1.202-bionic
---> 82688290b31f
Step 2/10 : ARG BUILDCONFIG=RELEASE
---> Running in 74f348453403
Removing intermediate container 74f348453403
---> f07df710b48e
Step 3/10 : ARG VERSION=1.0.0
---> Running in d1556dc14108
Removing intermediate container d1556dc14108
---> 63b311ef2174
Step 4/10 : WORKDIR .
---> Running in acd6a2b9f467
Removing intermediate container acd6a2b9f467
---> cecc23485351
Step 5/10 : COPY . /build/
Error processing tar file(exit status 1): write /build/Model/bin/Debug/netcoreapp3.1/Microsoft.Data.SqlClient.dll: no space left on device
I check the path Library/Containers/com.docker.docker/Data/vms/0/data and find the Docker.raw file is 59GB(don't know why it's so big).
Is there a way to enlarge the container size?

How to analyze image build that fails silently in CI tool?

My Docker image is failing during build in GitLab CI and it fails silently without giving any errors to work with. I can build the image locally and no problem whatsoever so the problem is in CI environment. Something that is not obvious causes the build to fail. After doing some research about this I've learned the best thing to do to SSH into the CI server and "poke around" to find out what's happening. In particular I've learned that I can get a log of the last layer before the build fails to get insight into why it might be failing. However, GitLab doesn't support direct SSH connection into CI server. Supports only fixed SSH commands executed towards the server from the build environment (.gitlab-ci.yml) which isn't very helpful because I need to use SSH to access build layers of the image.
What are my other options as to how can I debug / analyze an image during build in CI ?
Any feedback much appreciated.
Dockerfile:
###########
# BUILDER #
###########
# base image
FROM node:11.12.0-alpine as builder
# set working directory
WORKDIR /usr/src/app
RUN apk add --no-cache --virtual .gyp python make g++
# install app dependencies
ENV PATH /usr/src/app/node_modules/.bin:$PATH
COPY package.json /usr/src/app/package.json
COPY package-lock.json /usr/src/app/package-lock.json
RUN npm install --no-optional
RUN npm install react-scripts#2.1.8 -g --silent --no-optional
# set environment variables
ARG REACT_APP_USERS_SERVICE_URL
ENV REACT_APP_USERS_SERVICE_URL $REACT_APP_USERS_SERVICE_URL
ARG NODE_ENV
ENV NODE_ENV $NODE_ENV
# create build
COPY . /usr/src/app
RUN npm run build
#########
# FINAL #
#########
# base image
FROM nginx:1.15.9-alpine
# update nginx conf
RUN rm -rf /etc/nginx/conf.d
COPY conf /etc/nginx
# copy static files
COPY --from=builder /usr/src/app/build /usr/share/nginx/html
# expose port
EXPOSE 80
# run nginx
CMD ["nginx", "-g", "daemon off;"]
.gitlab-ci.yml file:
...
...
after_script:
- bash ./docker-push.sh
- docker-compose down
docker-push.sh script that builds the image for pushing into ECR on AWS:
echo "building the client image ..."
docker -D build $CLIENT_REPO -t $CLIENT:$COMMIT -f Dockerfile-prod --build-arg REACT_APP_USERS_SERVICE_URL="" # this line is failing
if [ $? -ne 0 ]; then
echo "Failure. Exiting now..."
exit 1
fi
docker -D tag $CLIENT:$COMMIT $REPO/$CLIENT:$TAG
docker -D push $REPO/$CLIENT:$TAG
docker build $USERS_REPO -t $USERS:$COMMIT -f Dockerfile-$DOCKER_ENV
docker tag $USERS:$COMMIT $REPO/$USERS:$TAG
docker push $REPO/$USERS:$TAG
docker build $USERS_DB_REPO -t $USERS_DB:$COMMIT -f Dockerfile
docker tag $USERS_DB:$COMMIT $REPO/$USERS_DB:$TAG
docker push $REPO/$USERS_DB:$TAG
docker build $SWAGGER_REPO -t $SWAGGER:$COMMIT -f Dockerfile-$DOCKER_ENV
docker tag $SWAGGER:$COMMIT $REPO/$SWAGGER:$TAG
docker push $REPO/$SWAGGER:$TAG
job log from gitlab ci (relevant part only):
Login Succeeded
building the client image ...
time="2020-04-14T08:54:23Z" level=debug msg="Skipping excluded path: .dockerignore"
time="2020-04-14T08:54:23Z" level=debug msg="Skipping excluded path: Dockerfile"
time="2020-04-14T08:54:23Z" level=debug msg="Skipping excluded path: Dockerfile-prod"
time="2020-04-14T08:54:23Z" level=debug msg="Skipping excluded path: Dockerfile-stage"
time="2020-04-14T08:54:23Z" level=debug msg="Skipping excluded path: .dockerignore"
time="2020-04-14T08:54:23Z" level=debug msg="Skipping excluded path: Dockerfile-prod"
time="2020-04-14T08:54:23Z" level=debug msg="Skipping excluded path: Dockerfile"
time="2020-04-14T08:54:23Z" level=debug msg="Skipping excluded path: Dockerfile-stage"
Step 1/25 : FROM node:11.12.0-alpine as builder
---> 09084e4ff58d
Step 2/25 : WORKDIR /usr/src/app
---> Using cache
---> 9c6639a8a785
Step 3/25 : RUN apk add --no-cache --virtual .gyp python make g++
---> Using cache
---> 0d5320ee514b
Step 4/25 : ENV PATH /usr/src/app/node_modules/.bin:$PATH
---> Using cache
---> c041f8c64b34
Step 5/25 : COPY package.json /usr/src/app/package.json
---> 02d18d67a517
Step 6/25 : COPY package-lock.json /usr/src/app/package-lock.json
---> 2d94e8e8fb6c
Step 7/25 : RUN npm install --no-optional
---> Running in 59660215041e
> cypress#4.1.0 postinstall /usr/src/app/node_modules/cypress
> node index.js --exec install
Installing Cypress (version: 4.1.0)
[08:55:20] Downloading Cypress [started]
[08:55:20] Downloading Cypress 0% 0s [title changed]
[08:55:20] Downloading Cypress 2% 5s [title changed]
...
...
[08:55:39] Unzipping Cypress 9% 167s [title changed]
[08:55:39] Unzipping Cypress 100% 0s [title changed]
[08:55:39] Unzipped Cypress [title changed]
[08:55:39] Unzipped Cypress [completed]
[08:55:39] Finishing Installation [started]
[08:55:40] Finished Installation /root/.cache/Cypress/4.1.0 [title changed]
[08:55:40] Finished Installation /root/.cache/Cypress/4.1.0 [completed]
You can now open Cypress by running: node_modules/.bin/cypress open
https://on.cypress.io/installing-cypress
added 2034 packages from 768 contributors and audited 38602 packages in 77.201s
found 1073 vulnerabilities (1058 low, 14 moderate, 1 high)
run `npm audit fix` to fix them, or `npm audit` for details
Saving cache
00:02
Uploading artifacts for successful job
00:02
Job succeeded

mvn install DskipTests error 'mv: cannot remove apache-maven-3.2.5 No such file or directory'

I got the issue by using following command.
cd metron-deployment/packaging/docker/rpm-docker
mvn clean install -DskipTests -PHDP-2.5.0.0 . .
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO]
[INFO] --- exec-maven-plugin:1.5.0:exec (docker-build) # metron-rpm ---
Sending build context to Docker daemon 842.5 MB
Step 1/13 : FROM centos:centos6
---> d0957ffdf8a2
Step 2/13 : RUN yum install -y tar
---> Using cache
---> bdc0c1cfe815
Step 3/13 : RUN yum install -y wget
---> Using cache
---> a39bcec938e0
Step 4/13 : RUN yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel
---> Using cache
---> 67857c9ce3c1
Step 5/13 : WORKDIR /usr/src
---> Using cache
---> afbc7a591163
Step 6/13 : RUN wget http://apache.cs.utah.edu/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.tar.gz
---> Using cache
---> 4ea0b2ddde0d
Step 7/13 : RUN tar xzvf apache-maven-3.2.5-bin.tar.gz
---> Using cache
---> eab37a7e2958
Step 8/13 : RUN mv apache-maven-3.2.5 /opt/maven
---> Running in ee91532580b7
mv: cannot remove `apache-maven-3.2.5/LICENSE': No such file or directory
mv: cannot remove `apache-maven-3.2.5/NOTICE': No such file or directory
mv: cannot remove `apache-maven-3.2.5/README.txt': No such file or directory
mv: cannot remove `apache-maven-3.2.5/bin/m2.conf': No such file or directory
Any idea please help
Thanks
I have updated below file. but still same error
vi /etc/profile
export M2_HOME=/opt/maven
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
export MAVEN_OPTS="-Xms512m -Xmx1024m"
source /etc/profile

Static Go Binaries w/ Docker - Entrypoint Not Found

I used Static Go Binaries with Docker on OSX by Nicola Paolucci to try to use static Go binary w/ Docker. I believe I followed every step correctly, but when I run the final image, I get the following error response from Docker.
NOTE The name of my service and executable are netverify
docker: Error response from daemon: Container command '/netverify' not found or does not exist..
My Dockerfile.static looks like the following...
#Create a minimal container to run a Golang static binary
FROM tianon/true
ADD netverify /
EXPOSE 8282
CMD ["/netverify"]
My Dockerfile.build looks like the following...
FROM golang
ADD Makefile /
WORKDIR /
RUN make setup
ADD . /go/src/github.com/eirwin/netverify
RUN make buildgo
CMD ["/bin/bash"]
My Makefile is the following...
GOCMD = go
GOBUILD = $(GOCMD) build
GOGET = $(GOCMD) get -v
GOCLEAN = $(GOCMD) clean
GOINSTALL = $(GOCMD) install
GOTEST = $(GOCMD) test
.PHONY: all
all: build
setup:
$(GOGET) github.com/gorilla/mux
buildgo:
GOOS=linux $(GOBUILD) -o netverify ./go/src/github.com/eirwin/netverify
builddocker:
docker build -t eirwin/netverify -f ./Dockerfile.build .
docker run -t eirwin/netverify /bin/true
docker cp `docker ps -q -n=1`:/netverify .
chmod 755 ./netverify
docker build --rm=true --tag=eirwin/netverify -f Dockerfile.static .
run: builddocker
docker run -p 8282:8282 eirwin/netverify
For the purpose of this post, lets assume I have the following as my golang application.
func main() {
router := mux.NewRouter()
router.HandleFunc("/ping", api.PingHandler).Methods("GET")
http.ListenAndServe(":8282", router)
}
When I run Make run everything seems to work except for when the image is ran.
I can see that the image builds correctly at ~8.5MB
eirwin/netverify latest eae16e146b91 3 seconds ago 8.63 MB
But when If docker run -p 8282:8282 eirwin/netverify is ran I get the following error...
docker: Error response from daemon: Container command '/netverify' not found or does not exist..
The go static build in your makefile is missing some options.
buildgo:
CGO_ENABLED=0 GOOS=linux go build -ldflags "-s" -a -installsuffix cgo -o netverify ./go/src/github.com/eirwin/netverify
The build process can capture the container ID to avoid timing issues.
Separate the tags for build and binary images.
builddocker:
docker build -t eirwin/netverify-build -f ./Dockerfile.build .
CID=$$(docker create eirwin/netverify-build); \
docker cp $$CID:/netverify .; \
docker rm $$CID
chmod 755 ./netverify
docker build --rm=true --tag=eirwin/netverify -f Dockerfile.static .
Your binary Dockerfile.static can start with the scratch blank image.
FROM scratch

Resources