How to start Mountebank in Docker? - docker

How can I use Docker to start Mountebank as a server? I am following this tutorial but I can't make it work.
This error appears:
warn: [mb:2525] dry running injection, use the isDryRun request field in your JavaScript to ignore...
error: [mb:2525] injection X=> SyntaxError: Unexpected token e
error: [mb:2525] source: "(function(request, logger) { return JSON.parse(request.data).hasOwnProperty('state'); })(scope, logger);"
error: [mb:2525] scope: {"requestFrom":"","data":"test","isDryRun":true}
The project is open source and CI is Travis. I have cross-posted this discussion to the Mountebank mailing list.

The problem appears to be that the base Docker image is using an old version of mountebank (v1.2.122). I'm not super familiar with Docker, but I assume it's caching the image originally built by Conrad. Your config file works fine with the latest version of mountebank; that just needs to be installed in the Docker container. - https://groups.google.com/forum/#!topic/mountebank-discuss/m-UrVZBR1sQ

Related

Cannot create docs for components in backstage docker error

I am trying to display docs stored in repository created by backstage io component on backstage-io /docs page UI, but when I am trying to access the docs I am getting the following error
Building a newer version of this documentation failed. Error: "Failed to generate docs from C:\\Users\\Admin\\AppData\\Local\\Temp\\backstage-enprxk into C:\\Users\\Admin\\AppData\\Local\\Temp\\techdocs-tmp-W6iVab; caused by Error: Docker container returned a non-zero exit code (1)"
Files in my repository
docs folder only having index.md
and mkdocs.yml have
nav:
Home: index.md
I was getting similar issues working on a local POC of Backstage. The biggest problem was that I needed to install pip, python, mkdocs, and mkdocs-techdocs-core (i.e. pip3 install mkdocs-techdocs-core). If you have done that and then followed everything in this documentation, then it should start working. Hope that helps. I spent a couple of days trying to get past these types of errors.
For me the above issue is fixed by using below as it was not working inside my container in kubernetes.
I changed app-config.yaml -
techdocs:
builder: 'local' # Alternatives - 'external'
generator:
runIn: 'local' // changed from docker to local here

Rinkeby contracts deployment Error: Timeout

I was trying to follow this tutorial:
https://docs.opensea.io/docs/1-structuring-your-smart-contract
And even found this extremely helpful YouTube video to guide me:
https://www.youtube.com/watch?v=lbXcvRx0o3Y&ab_channel=DanViau
But I've encountered a problem after installing and setting up everything I needed. The problem occured when I tried to deploy the contracts using this bash command:
truffle deploy --network rinkeby
The error message I got is:
Error: There was a timeout while attempting to connect to the network.
Check to see that your provider is valid.
If you have a slow internet connection, try configuring a longer timeout in your Truffle config. Use the networks[networkName].networkCheckTimeout property to do this.
at Timeout._onTimeout (C:\Users\alonb\.nvm\versions\node\v12.22.5\bin\node_modules\truffle\build\webpack:\packages\provider\index.js:56:1)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7)
It's not caused by slow internet connection - I know that because I have tried executing this command on 3 different WiFi connections, one at 200 Mb/s rate.
I have tried to change the truffle-config.js file and add a longer timeout threshold (like suggested here), but the only thing that changed was that the error message took much longer to appear.
Technical info - I'm using Git Bash, npm version 6.14.14, nvm version 0.38.0, node version 12.22.5.
Any suggestions? I'm lost.
Alon
I also ran into this error when following the same tutorial.
I use Alchemy (not Infura), and the issue was my API_KEY.
In other tutorials I've followed, the scripts require the full alchemy API Key (ex. "https://eth-rinkeby.alchemyapi.io/v2/<random-key>").
So, when I was following this tutorial, that is what I supplied. And, I ran into the error you reported.
But when I reviewed the truffle.js script provided by the tutorial authors, I found this:
const rinkebyNodeUrl = isInfura
? "https://rinkeby.infura.io/v3/" + NODE_API_KEY
: "https://eth-rinkeby.alchemyapi.io/v2/" + NODE_API_KEY;
Thus, the script was producing:
rinkebyNodeUrl = https://eth-rinkeby.alchemyapi.io/v2/https://eth-rinkeby.alchemyapi.io/v2/<**random-key**>
...which is clearly wrong.
Thus, ensuring I set my API_KEY environment variable only to random-key and not https://eth-rinkeby.alchemyapi.io/v2/https://eth-rinkeby.alchemyapi.io/v2/<random-key>, my contract deployed successfully.
Also, make sure you have enough ETH in your wallet on the Rinkeby network. Faucets always seem to work for a little while then stop working, so do some Google searches to find one that is currently functional.
The solution is incredibly easy -
Instead of using just the relevant part of the Alchemy key:
40Oo3XScVabXXXX8sePUEp9tb90gXXXX
I used the whole URL:
https://eth-rinkeby.alchemyapi.io/v2/40Oo3XScVabXXXX8sePUEp9tb90gXXXX
I had the same experience but when using hardhat not truffle.My internet connection was ok,try switching from Git bash to terminal(CMD).Use a completely new terminal avoid Gitbash and powershell.
Remove the function wrapper from provider inside the network configuration.
ropsten_infura: {
provider: new HDWalletProvider({
mnemonic: {
phrase: mnemonic
},
providerOrUrl: `https://ropsten.infura.io/v3/${project_id}`,
addressIndex
}),
network_id: 3
}
The rinkbery network has been decommissioned. Use Goerli or Sepolia network. Update your truffle config add a section for goerli in networks. E.g
goerli: {
provider: () =>
new HDWalletProvider(
mnemonic,
`https://goerli.infura.io/v3/${INFURAKEY}`
),
network_id: 5, // goerli's id
gas: 4500000, //
gasPrice: 10000000000,
}
The run the command
truffle deploy --network goerli

.Net Core web API Docker (Linux) - unable to load libMyCpp.so file

I have a .NetCore web API and and need to connect with a C++ shared library (libCppAppOutput.so). For this I am using DllImport inside the controller of the Web API as in the below code:
[DllImport("libCppAppOutput.so", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, EntryPoint = "methodNameinCppProject")]
public static extern int MethodNameInWebAPI(string param1, string param2);
When I am debugging it in Visual studio with Windows environment, I am getting an exception like
An attempt was made to load a program with an incorrect format.
(0x8007000B).
This may be because of trying to access a Linux file in Windows environment, if I am using a CppAppOutput.dll in place of libCppAppOutput.so I can successfully call the methods inside the dll. But my actual requirement is to run the entire application in Linux environment and to be proceed with .so file only, so I have created a docker image with target OS as Linux and tried to call the methods inside it from running docker with the below command :
docker run -p 8081:80 name_of_docker_image:tagname
Then I am getting an exception like:
Unable to load shared library 'libCppAppOutput.so' or one of its dependencies. In order to help diagnose loading problems, consider
setting the LD_DEBUG environment variable: libCppAppOutput.so: cannot
open shared object file: No such file or directory.
But I can see the file, libCppAppOutput.so is present inside the docker image by using the following commands,
docker create --name name_of_container name_of_docker_image:tagname
docker start name_of_container
docker exec -ti name_of_container /bin/bash
root#xyzabc:/app# ls
I am using below URL to test the application
http://localhost:8081/launchUrl/MethodNameInWebAPI/param1/param2
Please help me in this regard like how can I call a .so file from the Linux docker.
if this issue to be elaborated more, kindly comment and I will do.
Thanks in advance.
I could able to solve this issue with help from my colleagues and friends.
There was a dependency with libCppAppOutput.so (an XML parser). Even though that dependency package is installed in the container, it was missed to configure while creating the libCppAppOutput.so.
This was identified by executing ldl libCppAppOutput.so command in bash.
Thank you all for spend time on reading and analyzing the question !
Have more N more great coding days!

Bazel internal shell issue using windows

I am trying to migrate a huge project having visual studio and maven projects to bazel. I need to access our in house maven server which is encrypted. To get access I need the load the maven_jar skylark extension since the default impl does not support encryption (get error 401). using the extension leads to a lot of troubles, like:
ERROR: BUILD:4:1: no such package '#org_bouncycastle_bcpkix_jdk15on//jar': Traceback (most recent call last):
File ".../external/bazel_tools/tools/build_defs/repo/maven_rules.bzl", line 280
_maven_artifact_impl(ctx, "jar", _maven_jar_build_file_te...)
File ".../external/bazel_tools/tools/build_defs/repo/maven_rules.bzl", line 248, in _maven_artifact_impl
fail(("%s: Failed to create dirs in e...))
org_bouncycastle_bcpkix_jdk15on: Failed to create dirs in execution root.
The main issue seems to be the shell that needs to be provided to bazel in BAZEL_SH environment variables:
I am working under windows
I am using bazel 0.23.2
bazel seems to run a bash command using "bash" directly and not the one provided by env variable.
I got a ubuntu shell installed in windows. bazel was using everything from ubuntu, especially when using maven (settings.xml was using from ubuntu ~/.m2 and not from windows user)
after uninstalling ubuntu and making sure that bash in a cmd ends up in "command not found" I also removed the BAZEL_SH env var and bazel throws the message above
after setting the BAZEL_SH variable again it fails with the same error message
I am assuming that bazel gets a bash from somewhere or is ignoring the env variable. My questions are:
1. How to setup a correct shell?
2. Is BAZEL_SH needed when using current version?
For me the doc at bazel website about setup is outdated.
Cheers
Please consider using rules_jvm_external to manage your Maven dependencies. It supports both Windows and private repositories using HTTP Basic Authentication.
For me the doc at bazel website about setup is outdated.
The Bazel team is aware of this and will be updating our docs shortly.

AspNetCore:2.1 not found

Created a new .NET CORE 2.1 (preview) web app. Running it in local docker with Linux container
I am getting compiler error:
Error Building blobtest
Service 'blobtest' failed to build: manifest for microsoft/aspnetcore:2.1 not found.
My dotnetversion
C:\WINDOWS\system32>dotnet --version
2.1.300-preview2-008530
They have changed the repo for .NET Core 2.1 onwards to microsoft/dotnet.
Change your FROM statement to reference microsoft/dotnet using the following tags:
2.1-sdk
2.1-aspnetcore-runtime
2.1-runtime
Documentation on how to upgrade can be found here
I had this issue as well. I thought I'd update this post to show the fix here. Thanks to Marius Bidireac for the link to the resource.
Here is an excerpt from the original docker file
FROM microsoft/aspnetcore:2.0 AS base
FROM microsoft/aspnetcore-build:2.0 AS build
Here is an excerpt from the corrected docker file
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
FROM microsoft/dotnet:2.1-sdk AS build
If you are using GitLab CI, then these images don't work—maybe because they changed the names of the images again. See official page on Docker.
If I used the labels suggested by this answer,
image: microsoft/dotnet:2.2
Then, it kept giving the errors,
manifest for microsoft/dotnet:2.2 not found
Solution to this was to use the recent naming convention provided by Microsoft. Please see the Docker link I provided above. In my GitLab CI (.gitlab-ci.yml) file I used the following and it worked,
image: mcr.microsoft.com/dotnet/core/sdk:2.2
Now the build pipeline succeeds just fine.

Resources