VS Code Docker DevContainer with MonoRepo - visual-studio-code

I'm trying to create a single git repository with 2 python projects in it that share some of the configuration.
Specifically I'm trying to share the docker-compose.yaml.
The dir structrure is as following:
root
|
- docker-compose.yaml
+-P1
+ .devcontainer
- devcontainer.json
- docker-compose.yml
+-P2
+ .devcontainer
- devcontainer.json
- docker-compose.yml
Each of the devcontainer.json has the following in it:
"dockerComposeFile": [
"../../docker-compose.yaml",
"docker-compose.yml"
],
When I try to open each of P1 or P2 in DevContainer I'm getting the following error:
Any idea if that configuration is supported?

Seems like the error itself came from having a wrong path to environment variable file in docker-compose.yaml file.
And that VS Code does support mono repo.

Related

Unable to run/debug robot tests in vscode - robocorp extensions installed

I have installed Robocorp Code as well as Robot Framework Language Server and have configured them. However, I am still having errors when trying to run the tests via the code lens options.
Repo - A webapi repo with a specific folder containing all tests. Lets call it regression.
RF - 4.1.3
Python - 3.8
This is what happens when I click on Run on the code lens for any of the tests -
`PS C:\git\xxxx\regression> C:; cd 'C:\git\xxxx\regression'; &
'C:\Users\xxxx\AppData\Local\Temp\rf-ls-run\run_env_00_smh5defr.bat'
'-u'
'c:\Users\xxxx.vscode\extensions\robocorp.robotframework-lsp-0.47.2\src\robotframework_debug_adapter\run_robot__main__.py'
'--port' '54331' '--no-debug' '--argumentfile'
'C:\git\xxxx\regression\args-local.txt' '--pythonpath'
'c:\git\xxxx\regression\common\lib' '--variable'
'EXECDIR:C:/git/xxxx/regression'
'--prerunmodifier=robotframework_debug_adapter.prerun_modifiers.FilteringTestsSuiteVisitor'
'c:\git\xxxx\regression\api\api_Test.robot'
[ ERROR ] Parsing'--pythonpath' failed: File or directory to execute does not exist.
However, the test starts if I remove the argumentfile parameter but it, of course, fails because its missing arguments from the file.
Do note that the folder specified in pythopath exists and has some python libraries needed for the tests.

obfuscate JS before FireBase Deploy

I have started using Firebase to host an app I am building in js.
I want to be able to obfuscate my java script code before I deploy it to FireBase.
I couldn't find a way of doing this automatically with firebase, so I downloaded the closure compiler, and started writing a deploy.bat batch file that would....
Copy all my code and assets from my public folder to a deploy folder
Obfuscate the JS
Deploy the site to Firebase.
However now I have found out that you cant have separate folders for dev local hosting e.g. (public - using the emulator) and another folder for what should be deployed to firebase.
Could anyone suggest how I can get around this ?
You can split the folders into a "development" and "production" build. However care should be taken to ensure that your tests pass against your production build as well as the development build.
The following folder structure will allow to deploy your obfuscated code by calling npm run build followed by npm run deploy from the project/dev folder in your terminal.
- /project
- /prod
- .firebaserc
- firebase.json
- /public
- ... (obfuscated files)
- /dev
- .firebaserc
- firebase.json
- package.json
- /public
- ... (source files)
In project/dev/firebase.json, merge in this to get firebase deploy to deliberately crash if accidentally called from inside of project/dev:
"hosting": {
"predeploy": "node -e \"process.exit(1)\""
}
In project/dev/package.json, merge in this so that your code is built/obfuscated into the project/prod directory:
"scripts": {
"build": "npm run build-hosting && ...",
"build-hosting": "INSERT-TOOL-HERE --srcDir ./public --outDir ../prod/public",
"deploy": "npm run deploy-hosting && ...",
"deploy-hosting": "pushd ../prod && firebase deploy --only hosting && popd",
}

Yarn 2 init, add failing

I'm experimenting with yarn 2 and faceplanting.
I created a new folder: /projects/yarn2/
As per their install guide https://yarnpkg.com/getting-started I ran
cd /projects/yarn2/
yarn set version berry
yarn init
then (as per their guide https://yarnpkg.com/getting-started/usage )
yarn add react
and got the following error:
Usage Error: The nearest package directory (/projects/yarn2) doesn't seem to be part of the project declared in /projects.
- If the project directory is right, it might be that you forgot to list yarn2 as a workspace.
- If it isn't, it's likely because you have a yarn.lock or package.json file there, confusing the project root detection.
$ yarn add [--json] [-E,--exact] [-T,--tilde] [-C,--caret] [-D,--dev] [-P,--peer] [-O,--optional] [--prefer-dev] [-i,--interactive] [--cached] ...
What am I doing wrong?
You either don't have package.json or yarn.lock which confuses yarn if the package is added in the workspace or not. Just run the following command and I think your problem must be solved.
cd <folder_name>/<project_name>
touch yarn.lock
yarn
Check to see if you have a package.json or yarn.lock file in your /projects directory. If you do, clear it/them out and this should start working.
To add to the previous answers what worked for me was:
It seems to be that yarn.lock file is what's really required, so if you have started with yarn v1.x and did yarn init - then you will have a package.json file in the project dir already.
If you now switch over to yarn v2 by doing yarn set berry, and want to add a package by yarn add [whatever] it will fail. You can work around that by creating an empty file by: touch yarn.lock (or on windows just cat '' > yarn.lock) after that it should work fine.
I figured out an even better / faster way to do it now, just do this in an empty project folder:
yarn init -2
this will initialize a new yarn v2 project folder with .yarnrc.yml, package.json, and the .yarn folder, also initializes an empty .git folder and adds a proper .gitignore. check by yarn --version - should echo v2.x.x
Usage Error: The nearest package directory (/<path_to_folder>/<project_name>) doesn't seem to be part of the project declared in /<path_to_folder>.
Solution:
Search for yarn.lock and package.json files inside /<path_to_folder> and delete them!
you have to remove yarn.lock and package.json file in your root directory ,some times there may be .yarnrc yarnyml files in you root directory you have to remove them also.

How to read resource in scala project when deployed in docker

im new to scala and sbt and im building a project and reading a model file (.h5) using the org.nd4j.linalg.io.ClassPathResource class. The h5 file is located under the resources folder and it works well when running the project locally using Intelij.
However, when the app runs on the docker i get the following error
java.io.FileNotFoundException: class path resource [scala/Product.class] cannot be opened because it does not exist
when i print the path which the app looking for i see that it is the root of my jar(when local), and root root folder of the machine in the docker environment.
i understand that whatever runs my app in the docker can't access the resources inside my jar.
My question is how do i use resources without changing the code before i deployment.
I have tried adding the following to the build.sbt file
mappings.in(Universal) += {((baseDirectory.value / "main" / "resources" / "my_model.h5"), "my_model.h5")}

How to build Conda env on Mac using Windows yml file?

I'm creating Conda create environment from yml I generated on Windows' Miniconda install. I need to create same environment on OS X. Following the advise found here on SO I used the --no-builds option.
Also, the names of some packages under section ResolvePackageNotFound are clearly (many if not all) specific to Windows:
- m2w64-gmp=6.1.0
- m2w64-gcc-libs-core=5.3.0
- m2w64-gcc-libs=5.3.0
- vc=14.1
- vs2015_runtime=15.5.2
- msys2-conda-epoch=20160418
- menuinst=1.4.14
- icc_rt=2019.0.0
- m2w64-libwinpthread-git=5.0.0.4634.697f757
- pywinpty=0.5.5
- wincertstore=0.2
- m2w64-gcc-libgfortran=5.3.0
- win_inet_pton=1.1.0
- winpty=0.4.3
I removed all of these from the yml file. Even then it's stalled at the following screen:
(base) MacBook-Air:Anaconda.d xtian$ conda env create -f 32b-qb-2019-10-05.yml
Collecting package metadata (repodata.json): done
Solving environment: \
Found conflicts! Looking for incompatible packages.
This can take several minutes. Press CTRL-C to abor|
Examining openssl: 10%|█████████▍ | 29/279 [00:00<00:00, 3729.87it- ]
Comparing specs that have this dependency: 16%|██████████▉ | 16/101 [05:53<31:19, 22.11s/it]
Finding shortest conflict path for openssl[version='>=1.0.2p,<1.0.3a']: 38%|███████████████▊ | 6/16 [02:39<06:23, 38.32s/it]
This process is progressing at an astonishingly slow pace, and hasn't got past openssl ... 29/279. Should I wait and trust Conda can figure this all out?
Or,
Do I need another strategy--
I'm wondering if I can't remove the offending packages, each in turn, and create a series of yml files to install in order using, $ conda env update --prefix ./env --file environment.yml --prune, because whatever finally works here I know I'm going to need to use it on another machine so I can share the project env with a colleague.
Any other suggestions?
Short answer: Try deleting the packages that your system is getting stuck on from the .yml file. i.e., remove "openssl" from .yml file.
I have been running into the same issue trying to install a .yml file created in a Windows system to a Mac system. I basically followed the same procedure you did:
-Created yml file using the --no-builds option.
-Attempted to create environment on Mac system and had several windows specific packages left under ResolvePackageNotFound section (listed below)
m2w64-libwinpthread-git=5.0.0.4634.697f757
pyreadline=2.1
pywinpty=0.5.5
m2w64-gcc-libgfortran=5.3.0
vc=14
m2w64-gcc-libs-core=5.3.0
m2w64-gmp=6.1.0
wincertstore=0.2
icc_rt=2019.0.0
m2w64-gcc-libs=5.3.0
vs2015_runtime=14.15.26706
winpty=0.4.3
msys2-conda-epoch=20160418
-Deleted those from the yml file
-Attempted to create environment from updated yml file and received the following conflicts:
- Found conflicts! Looking for incompatible packages.
My system also got stuck trying to solve the "openssl" conflict along with a "_tflow_select". I ended up deleting those and was able to create my environment and run the code without too much trouble.