Development environment setup github and browser sync - browser-sync

browser-sync start --server --directory --files "*"
browser-sync : File C:\Users\Sumithra\AppData\Roaming\npm\browser-sync.ps1 cannot be loaded because running scripts is
disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ browser-sync start --server --directory --files "*"
+ ~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
what to do ?
please anyone help me for this

Related

Gitlab CI runner not taking the environmental variable of the local system

I am running a simple hello world python program in gitlab ci. While running it in pipeline it throws the error python not used as the name of a cmdlet.
here is my yml file
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "push"
when: always
stages:
- Test
- Build
Test_stage:
tags:
- PC_RUNNER
stage: Test
script:
- echo "Test stage started"
- cd .\test\test
- python hello.py
and here is the error
$ cd .\test\test
$ python helloworld.py
python : The naming "python" was not used as the name of a cmdlet, function, script file, or executable
program recognized. Check the spelling of the name, or if the path is correct (if included), and
repeat the process.
In C:\WINDOWS\TEMP\build_script3952941328\script.ps1:235 characters:1
+ python helloworld.py
+~~~
+ CategoryInfo : ObjectNotFound: (python:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
But when i change the command and give the full path where my python is installed it works
script:
- echo "Test stage started"
- cd .\test\test
- C:\users\abc\python\python.exe hello.py
I have added the environmental paths correctly as i have already double checked it. From the Gitlab documentation i came to know that we can also add environment variable in gitlab runner TOML file which i did as follows
executor = "shell"
shell = "powershell"
environment = ["ENV=C:\users\abc\python\", "LC_ALL=en_US.UTF-8"]
But the gitlab pipeline still throws the above error. Does someone knows what am i doing wrong here? Thanks in advance

Cannot use msbuild from docker image in gitlab

I have found a docker image with msbuild and nuget installed. I want to use msbuild to build my .NET framework project, but it returns the following error:
$ & "$env:MSBUILD_PATH" /p:Configuration=Release /clp:ErrorsOnly
& : The term 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe' is not
recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if
a path was included, verify that the path is correct and try again.
At line:1 char:3
+ & "$env:MSBUILD_PATH" /p:Configuration=Release /clp:ErrorsOnly
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Program File...Bin\MSBuild.exe:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Here is my yaml file:
.shared_windows_runners:
tags:
- shared-windows
- windows
- windows-1809
variables:
MSBUILD_PATH: 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe'
NUGET_PATH: 'C:\Nuget\nuget.exe'
stages:
- build
build:
extends:
- .shared_windows_runners
stage: build
image: compulim/msbuild
script:
- echo "start building"
- '& "$env:MSBUILD_PATH" /p:Configuration=Release /clp:ErrorsOnly'
- '& "$env:MSBUILD_PATH" WebCICD\WebCICD.csproj /p:DeployOnBuild=true /p:Configuration=Release /P:PublishProfile=FolderProfile.pubxml'
- Tree
I found this docker image by googling "docker msbuild image".
I thought the image could let me use the file path to build the project directly. Am I wrong?
Is there anything I am missing?
Thanks

Running a PowerShell script on a remote machine doesn't work in Azure Devops

I am trying to run a Powershell script on a remote machine via ssh. I have configured Azure release but I am getting a very strange error.
This is how my config file looks like
steps:
- task: SSH#0
displayName: 'Run shell script on remote machine'
inputs:
sshEndpoint: 'Dev SSH service'
failOnStdErr: false
runOptions: script
scriptPath: '$(Build.SourcesDirectory)/Pipelines/Scenarios/test.ps1'
readyTimeout: '20000'
This is what my Powershell script looks like:
Write-Host "Hello, World!"
The remote computer is configured with ssh via PowerShell.
I am getting the error as shown in the picture
Transcription:
tr -d '\015' <./test.ps1> ./test.ps1._unix
##[error]At line:1 char:14
##[error]+ tr -d '\015' <./test.ps1> ./test.ps1._unix
##[error]The '<' operator is reserved for future use.
##[error] + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
##[error] + FullyQualifiedErrorId : RedirectionNotSupported
##[error]Error: Command tr -d '\015' <./test.ps1> ./test.ps1._unix exited with code 1.
I solved the problem. I have created a System.Debug variable. I saw how SSH0 works, in the end I just copy the script to the remote machine and execute it by setting Run = commands.
- task: CopyFilesOverSSH#0
displayName: 'Copy scripts to on remote machine'
inputs:
sshEndpoint: 'Dev SSH service'
sourceFolder: '$(Build.SourcesDirectory)\Pipelines\Scenarios'
contents: '**.ps1'
targetFolder: 'C:\Test\Scenarios'
cleanTargetFolder: false
overwrite: true
failOnEmptySource: false
flattenFolders: true
- task: SSH#0
inputs:
sshEndpoint: 'Dev SSH service'
runOptions: 'commands'
commands: 'C:\Test\Scenarios\test.ps1'
readyTimeout: '20000'

Docker Container must be ran on elevated privelidges

I am trying to create a docker container for my node.js application. When I run the docker desktop in administrator and Powershell in Administrator I get the following error.
PS C:\Users\User\NodejsWebApp1\NodejsWebApp1> FROM node:12
At line:1 char:1
+ FROM node:12
+ ~~~~
The 'from' keyword is not supported in this version of the language.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ReservedKeywordNotAllowed
PS C:\Users\User\NodejsWebApp1\NodejsWebApp1>
PS C:\Users\User\NodejsWebApp1\NodejsWebApp1> # Create app directory
PS C:\Users\User\NodejsWebApp1\NodejsWebApp1> WORKDIR /usr/src/app
WORKDIR : The term 'WORKDIR' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ WORKDIR /usr/src/app
+ ~~~~~~~
+ CategoryInfo : ObjectNotFound: (WORKDIR:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\Users\User\NodejsWebApp1\NodejsWebApp1>
PS C:\Users\User\NodejsWebApp1\NodejsWebApp1> # Install app dependencies
PS C:\Users\User\NodejsWebApp1\NodejsWebApp1> # A wildcard is used to ensure both package.json AND package-lock.json are copied
PS C:\Users\User\NodejsWebApp1\NodejsWebApp1> # where available (npm#5+)
PS C:\Users\User\NodejsWebApp1\NodejsWebApp1> COPY package*.json ./
COPY : Cannot overwrite the item
C:\Users\User\NodejsWebApp1\NodejsWebApp1\package-lock.json with itself.
At line:1 char:1
+ COPY package*.json ./
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (C:\Users\User\N...ckage-lock.json:String)
[Copy-Item], IOException
+ FullyQualifiedErrorId :
CopyError,Microsoft.PowerShell.Commands.CopyItemCommand
COPY : Cannot overwrite the item
C:\Users\User\NodejsWebApp1\NodejsWebApp1\package.json with itself.
At line:1 char:1
+ COPY package*.json ./
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (C:\Users\User\N...p1\package.json:String) [Copy-Item], IOException
+ FullyQualifiedErrorId :
CopyError,Microsoft.PowerShell.Commands.CopyItemCommand
PS C:\Users\User\NodejsWebApp1\NodejsWebApp1>
PS C:\Users\User\NodejsWebApp1\NodejsWebApp1> RUN npm install
RUN : The term 'RUN' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct
and try again.
At line:1 char:1
+ RUN npm install
+ ~~~
+ CategoryInfo : ObjectNotFound: (RUN:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\Users\User\NodejsWebApp1\NodejsWebApp1> # If you are building your code
for production
PS C:\Users\User\NodejsWebApp1\NodejsWebApp1> # RUN npm ci --only=production
PS C:\Users\User\NodejsWebApp1\NodejsWebApp1>
PS C:\Users\User\NodejsWebApp1\NodejsWebApp1> # Bundle app source
PS C:\Users\User\NodejsWebApp1\NodejsWebApp1> COPY . .
COPY : Cannot overwrite the item C:\Users\User\NodejsWebApp1\NodejsWebApp1 with
itself.
At line:1 char:1
+ COPY . .
+ ~~~~~~~~
+ CategoryInfo : WriteError: (C:\Users\User\N...1\NodejsWebApp1:String)
[Copy-Item], IOException
+ FullyQualifiedErrorId :
CopyError,Microsoft.PowerShell.Commands.CopyItemCommand
PS C:\Users\User\NodejsWebApp1\NodejsWebApp1>
PS C:\Users\User\NodejsWebApp1\NodejsWebApp1> EXPOSE 3000
EXPOSE : The term 'EXPOSE' is not recognized as the name of a cmdlet, function,
script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path
is correct and try again.
At line:1 char:1
+ EXPOSE 3000
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (EXPOSE:String) [],
CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\Users\User\NodejsWebApp1\NodejsWebApp1> CMD [ "node", "server.js"
]ect.:ect.:
Sorry about the mess of error, but that is what it was printing out!
The command I was running was
docker build -t name .
This is my DockerFile
FROM node:12
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm#5+)
COPY package*.json ./
RUN npm install
# Bundle app source
COPY . .
EXPOSE 3000
CMD [ "node", "server.js" ]
Should I maybe try doing this in Linux as I am currently running Windows 10, would this be a greater option.
Many thanks. Jeff

Unable to run NodeJS microservices through Docker containers

I was getting started with Docker, created couple of tiny Express(NodeJS) services.
Plan is to run the microservices inside Docker containers and then establish a inter-communication between them using Docker Compose service names.
Here is the Github repo of this simple project. Am able to build images with below commands :
cd books
docker build -t node-micro/books .
cd auth
docker build -t node-micro/auth .
Commands to start containers :
docker run -d -p 6677:6677 node-micro/auth
docker run -d -p 7766:7766 node-micro/books
But when i hit below URL's there is no response, which was working fine couple of day's before :
http://localhost:6677/
http://localhost:7766/
And have no clue what's happening with docker compose. No luck on accessing same URL's as mentioned above after stoping all containers, delete all images & ran this command :
docker-compose up -d
Need some help on bringing up the containers individually and also through docker-compose.
I can see in each of your micro-service, your application is running on ports 3000 in the container but you are exposing 7766 and 6677 in your docker-compose.yml
Please check the below docker-compose.yml
version: '3'
services:
books:
build: './books'
ports:
- "7766:3000"
depends_on:
- auth
auth:
build: './auth'
ports:
- "6677:3005"
and then run the below command
docker-compose up --build
--build will build the images as well.
Then, you should be able to access the service
http://localhost:6677/
http://localhost:7766/
Output
docker-compose up --build
Creating network "node_microservices_default" with the default driver
Building auth
Step 1/7 : FROM node:10-alpine
---> 0aa7bb41deca
Step 2/7 : WORKDIR /usr
---> Running in a1dc67b70538
Removing intermediate container a1dc67b70538
---> 5fc74fc80a14
Step 3/7 : COPY package*.json ./
---> 454f1b7aba87
Step 4/7 : RUN npm install
---> Running in a24eea8b79d4
npm WARN auth#1.0.0 No description
npm WARN auth#1.0.0 No repository field.
added 50 packages from 37 contributors and audited 50 packages in 8.58s
found 0 vulnerabilities
Removing intermediate container a24eea8b79d4
---> 31b31ff4516e
Step 5/7 : COPY . .
---> 1eeaa8e70300
Step 6/7 : EXPOSE 3000
---> Running in fc798167dbcd
Removing intermediate container fc798167dbcd
---> 4d964d25c099
Step 7/7 : CMD ["npm", "start"]
---> Running in 3c28d92f9ef6
Removing intermediate container 3c28d92f9ef6
---> 514f68d11d7c
Successfully built 514f68d11d7c
Successfully tagged node_microservices_auth:latest
Building books
Step 1/7 : FROM node:10-alpine
---> 0aa7bb41deca
Step 2/7 : WORKDIR /usr
---> Using cache
---> 5fc74fc80a14
Step 3/7 : COPY package*.json ./
---> 56addb6c75a5
Step 4/7 : RUN npm install
---> Running in 4864fb7a171c
npm WARN books#1.0.0 No description
npm WARN books#1.0.0 No repository field.
added 50 packages from 37 contributors and audited 50 packages in 5.111s
found 0 vulnerabilities
Removing intermediate container 4864fb7a171c
---> 82bb2cd54357
Step 5/7 : COPY . .
---> 12893a93e82e
Step 6/7 : EXPOSE 3000
---> Running in 1301e29dbd52
Removing intermediate container 1301e29dbd52
---> c26948ebcb3b
Step 7/7 : CMD ["npm", "start"]
---> Running in db948866a121
Removing intermediate container db948866a121
---> 703b901d7bc4
Successfully built 703b901d7bc4
Successfully tagged node_microservices_books:latest
Creating node_microservices_auth_1 ... done
Creating node_microservices_books_1 ... done
Attaching to node_microservices_auth_1, node_microservices_books_1
auth_1 |
auth_1 | > auth#1.0.0 start /usr
auth_1 | > node index.js
auth_1 |
auth_1 | Running on port 3005
auth_1 | --------------------------
books_1 |
books_1 | > books#1.0.0 start /usr
books_1 | > node index.js
books_1 |
books_1 | Running on port 3000
books_1 | --------------------------
You are exposing from both Dockerfiles the port 3000. Replace the port for each microservice in docker-compose.yml file.
- "7766:3000"
- "6677:3000"
The mapping for ports is wrong. In both Dockerfile you are exposing the port 3000.
So you must to map the ports 6677 and 7766 to the exposed port on the Dockerfile.
To fix this, on your docker-compose.yml you must to config ports like this:
version: '3'
services:
books:
build: './books'
ports:
- "7766:3000"
depends_on:
- auth
auth:
build: './auth'
ports:
- "6677:3000"

Resources