Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Running the SPA web app in docker on macOS #158

Closed
ChristianWeyer opened this issue Apr 6, 2017 · 23 comments
Closed

Running the SPA web app in docker on macOS #158

ChristianWeyer opened this issue Apr 6, 2017 · 23 comments
Assignees

Comments

@ChristianWeyer
Copy link

When building the SPA on macOS, building with npm is successful.
But when executing docker-compose -f docker-compose.ci.build.yml up I get this error:

eShopOnContainers git:(dev) ✗ Docker-compose -f docker-compose.ci.build.yml up
Creating eshoponcontainers_ci-build_1
Attaching to eshoponcontainers_ci-build_1
ci-build_1  | /src/src/Web/WebSPA /src
ci-build_1  |
ci-build_1  | > [email protected] install /src/src/Web/WebSPA/node_modules/node-sass
ci-build_1  | > node scripts/install.js
ci-build_1  |
ci-build_1  | node-sass build Binary found at /src/src/Web/WebSPA/node_modules/node-sass/vendor/linux-x64-48/binding.node
ci-build_1  |
ci-build_1  | > [email protected] postinstall /src/src/Web/WebSPA/node_modules/node-sass
ci-build_1  | > node scripts/build.js
ci-build_1  |
ci-build_1  | Binary found at /src/src/Web/WebSPA/node_modules/node-sass/vendor/linux-x64-48/binding.node
ci-build_1  | Testing binary
ci-build_1  | Bus error
ci-build_1  |
ci-build_1  | npm ERR! Linux 4.9.13-moby
ci-build_1  | npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "rebuild" "node-sass"
ci-build_1  | npm ERR! node v6.10.0
ci-build_1  | npm ERR! npm  v3.10.10
ci-build_1  | npm ERR! code ELIFECYCLE
ci-build_1  | npm ERR! [email protected] postinstall: `node scripts/build.js`
ci-build_1  | npm ERR! Exit status 135
ci-build_1  | npm ERR!
ci-build_1  | npm ERR! Failed at the [email protected] postinstall script 'node scripts/build.js'.
ci-build_1  | npm ERR! Make sure you have the latest version of node.js and npm installed.
ci-build_1  | npm ERR! If you do, this is most likely a problem with the node-sass package,
ci-build_1  | npm ERR! not with npm itself.
ci-build_1  | npm ERR! Tell the author that this fails on your system:
ci-build_1  | npm ERR!     node scripts/build.js
ci-build_1  | npm ERR! You can get information on how to open an issue for this project with:
ci-build_1  | npm ERR!     npm bugs node-sass
ci-build_1  | npm ERR! Or if that isn't available, you can get their info via:
ci-build_1  | npm ERR!     npm owner ls node-sass
ci-build_1  | npm ERR! There is likely additional logging output above.
ci-build_1  |
ci-build_1  | npm ERR! Please include the following file with any support request:
ci-build_1  | npm ERR!     /src/src/Web/WebSPA/npm-debug.log
eshoponcontainers_ci-build_1 exited with code 1

Already tried to run this first from the CLI:
npm rebuild node-sass

before running the docker-compose -f docker-compose.ci.build.yml up

But did not help.

@marcote
Copy link

marcote commented Jun 27, 2017

I had a similar issue, but running yarn install instead of npm install did the trick. I still don't know the root cause, but it seems npm went nuts.

HTH someone

@Shawn-Fan
Copy link

Shawn-Fan commented Aug 1, 2017

I used "npm install [email protected]" from "Build the SPA app with NPM error npm run build:prod #253", the problem solved. Everything works fine but webspa--"http://localhost:5104". I use "docker ps" and webspa looks like fine as following ...
Iams-MacBook:~ iam$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a949bbd77506 eshop/webmvc:latest "dotnet WebMVC.dll" 8 days ago Up 13 minutes 0.0.0.0:5100->80/tcp eshop_webmvc_1
0c2b145c771b eshop/webspa:latest "dotnet WebSPA.dll" 8 days ago Up 13 minutes 0.0.0.0:5104->80/tcp eshop_webspa_1
.......
any idea?

@danbarua
Copy link

danbarua commented Aug 8, 2017

I get

ERROR in ./Client/main.ts
Module build failed: TypeError: Cannot read property 'newLine' of undefined
    at Object.getNewLineCharacter (/Users/dbarua/Code/eShopOnContainers/src/Web/WebSPA/node_modules/typescript/lib/typescript.js:9514:20)
    at Object.createCompilerHost (/Users/dbarua/Code/eShopOnContainers/src/Web/WebSPA/node_modules/typescript/lib/typescript.js:63770:26)
    at Object.ngcLoader (/Users/dbarua/Code/eShopOnContainers/src/Web/WebSPA/node_modules/@ngtools/webpack/src/loader.js:380:33)
 @ multi ./Client/main.ts

ERROR in ./Client/polyfills.ts
Module build failed: TypeError: Cannot read property 'newLine' of undefined
    at Object.getNewLineCharacter (/Users/dbarua/Code/eShopOnContainers/src/Web/WebSPA/node_modules/typescript/lib/typescript.js:9514:20)
    at Object.createCompilerHost (/Users/dbarua/Code/eShopOnContainers/src/Web/WebSPA/node_modules/typescript/lib/typescript.js:63770:26)
    at Object.ngcLoader (/Users/dbarua/Code/eShopOnContainers/src/Web/WebSPA/node_modules/@ngtools/webpack/src/loader.js:380:33)
 @ multi ./Client/polyfills.ts

@CESARDELATORRE
Copy link
Collaborator

Did you followed de SPA app Setup procedure at the Wiki?
Npm install, etc. at the SPA app?

@danbarua
Copy link

danbarua commented Aug 8, 2017

Yep, neither npm install nor npm install [email protected] worked

@CESARDELATORRE
Copy link
Collaborator

@danbarua I had a few issues yesterday with a fresh cloned copy when running "npm install", "npm install [email protected]", "npm rebuild node-sass" and "npm rebuild node-sass".
It looks like npm is not very reliable, initially. Not sure what's the issue. But I tried running the commands quite a few times and then the errors were gone and the SPA app works ok...

@eiximenis
Copy link
Contributor

eiximenis commented Aug 10, 2017

Hi @danbarua

I reached the same error using Node 8 on both Windows 10 and Ubuntu, starting from a fresh repo.

Try to follow these steps:

  1. Remove angular-cli from both local and global
npm uninstall -g @angular/cli
npm uninstall --save-dev @angular/cli
  1. Install global angular cli
npm install -g @angular/cli
  1. Remove node_modules folder

  2. Reinstall packages

npm install @angular/cli --save-dev
npm install

That worked for me.

(Not sure if global angular cli is needed but I put here because it is recommended to have it by Angular team)

I updated the dev branch with:

  1. A new package.json with angular/[email protected] referenced
  2. A updated package-lock.json in case you're using npm 5+

I've tested with:

  1. Windows 10 + node 8: Worked OK
  2. Ubuntu 17.04 + node 8: Worked OK
  3. Windows 10 + node 6x: Worked OK

Please, keep in mind that you can run into issue #268

Thanks.

@danbarua
Copy link

danbarua commented Aug 10, 2017

So I managed to run npm run build:prod ok after following the steps above, running npm run clean --force and doing a checkout of the dev branch.

I'm getting this on docker-compose up:

WARNING: The ESHOP_AZURE_STORAGE_CATALOG_NAME variable is not set. Defaulting to a blank string.
WARNING: The ESHOP_AZURE_STORAGE_CATALOG_KEY variable is not set. Defaulting to a blank string.
WARNING: The ESHOP_AZUREFUNC_CAMPAIGN_DETAILS_URI variable is not set. Defaulting to a blank string.
WARNING: The ESHOP_AZURE_STORAGE_MARKETING_NAME variable is not set. Defaulting to a blank string.
WARNING: The ESHOP_AZURE_STORAGE_MARKETING_KEY variable is not set. Defaulting to a blank string.
Building webspa
Step 1/6 : FROM microsoft/aspnetcore:1.1.2
 ---> ed7905eba193
Step 2/6 : ARG source
 ---> Using cache
 ---> e9295a63f51f
Step 3/6 : WORKDIR /app
 ---> Using cache
 ---> 2b001aab4841
Step 4/6 : EXPOSE 80
 ---> Using cache
 ---> c30c424e0060
Step 5/6 : COPY ${source:-obj/Docker/publish} .
ERROR: Service 'webspa' failed to build: COPY failed: stat /var/lib/docker/tmp/docker-builder711271253/obj/Docker/publish: no such file or directory

@eiximenis
Copy link
Contributor

Some error happened when building the webspa, so /src/Web/WebSPA/obj/Docker/publish is empty (or do not exist).

Doing npm run:prod it is not enough to build all SPA (backend needs to be built too). Could you go to src/Web/WebSPA and:

  1. Remove obj/Docker/publish folder if exists
  2. run dotnet restore
  3. run dotnet publish -o obj/Docker/publish

Check if obj/Docker/publish folder exists (if there were no errors, it should exist). Then you could run docker-compose up again.

If any error, please post the dotnet publish output here :)

@danbarua
Copy link

danbarua commented Aug 10, 2017

dotnet publish -o obj/Docker/publish

Microsoft (R) Build Engine version 15.1.1012.6693
Copyright (C) Microsoft Corporation. All rights reserved.

  DataProtection -> /Users/dbarua/Code/eShopOnContainers/src/BuildingBlocks/DataProtection/DataProtection/bin/Debug/netcoreapp1.1/DataProtection.dll
  Microsoft.Extensions.HealthChecks -> /Users/dbarua/Code/eShopOnContainers/src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/bin/Debug/netstandard1.3/Microsoft.Extensions.HealthChecks.dll
  Microsoft.AspNetCore.HealthChecks -> /Users/dbarua/Code/eShopOnContainers/src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/bin/Debug/netstandard1.3/Microsoft.AspNetCore.HealthChecks.dll
Startup.cs(34,17): warning CS0618: 'ConfigurationExtensions.AddUserSecrets(IConfigurationBuilder)' is obsolete: 'This method is obsolete and will be removed in a future version. The recommended alternative is .AddUserSecrets(string userSecretsId) or .AddUserSecrets<TStartup>().' [/Users/dbarua/Code/eShopOnContainers/src/Web/WebSPA/WebSPA.csproj]
  WebSPA -> /Users/dbarua/Code/eShopOnContainers/src/Web/WebSPA/bin/Debug/netcoreapp1.1/WebSPA.dll
  npm ERR! Cannot read property '0' of undefined

  npm ERR! A complete log of this run can be found in:
  npm ERR!     /Users/dbarua/.npm/_logs/2017-08-10T14_22_38_288Z-debug.log
/Users/dbarua/Code/eShopOnContainers/src/Web/WebSPA/WebSPA.csproj(61,5): error MSB3073: The command "npm install" exited with code 1.

Looks like #268

@eiximenis
Copy link
Contributor

I beg one dollar, that you are using npm 5.3.0 :)

If so, try downgrading to npm 5.2.0 (npm install -g [email protected]) and run again. See issue #268

Let me know!

@danbarua
Copy link

Yep, just tried that, dotnet publish worked.

@danbarua
Copy link

Now docker-compose up fails with:

Building catalog.api
Step 1/6 : FROM microsoft/aspnetcore:1.1.2
 ---> ed7905eba193
Step 2/6 : ARG source
 ---> Using cache
 ---> e9295a63f51f
Step 3/6 : WORKDIR /app
 ---> Using cache
 ---> 2b001aab4841
Step 4/6 : EXPOSE 80
 ---> Using cache
 ---> c30c424e0060
Step 5/6 : COPY ${source:-obj/Docker/publish} .
ERROR: Service 'catalog.api' failed to build: COPY failed: stat /var/lib/docker/tmp/docker-builder963768568/obj/Docker/publish: no such file or directory

😆

@danbarua
Copy link

On Catalog.API

running dotnet publish -o obj/Docker/Publish

gives

CSC : error CS0009: Metadata file '/Users/dbarua/Code/eShopOnContainers/src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/bin/Debug/netstandard1.3/Microsoft.AspNetCore.HealthChecks.dll' could not be opened -- PE image doesn't contain managed metadata. [/Users/dbarua/Code/eShopOnContainers/src/Services/Catalog/Catalog.API/Catalog.API.csproj]

@eiximenis
Copy link
Contributor

This is a very strange error, and sounds more like an error of roslyn compiler maybe. Not sure.

@CESARDELATORRE where we can ask for help about this issue?

@CESARDELATORRE
Copy link
Collaborator

@eiximenis I'll forward to a few folks in the .NET team. I'll come back if we get workarounds.

@Shawn-Fan
Copy link

Shawn-Fan commented Aug 17, 2017

"docker-compose up" works well in my machine, I met another problem as i mentioned before. I run "WebSPA" project as single project( just commented some codes in the middleware in startup.cs), it works as expected.
It looks like the ASP.NET core 1.1 + Angular 4 works fine, and other Projects(http://localhost:5100, http://localhost:5107, ......) as well. I am wondering if there is something wrong in "optimized dockers images" ?

@lurumad
Copy link

lurumad commented Aug 24, 2017

Hi folks,

I've run succesfully the eShopOnContainers in my MAC and I want to share with you the steps and the problems I've found:

First, install the correct software:

If you work with a fork on dev branch (Remember currently this works on dev branch until merge in master), please keeping your fork up to date following this steps https://gist.github.com/CristinaSolana/1885435 to ensure you are using the lastest version of node packages such us angular-cli 1.3.0 or you will receive some errors when you run docker-compose -f docker-compose.ci.build.yml up because the command npm run build:prod will fail.

After that, you can run again docker-compose -f docker-compose.ci.build.yml up , sometimes I had to execute 2 times because not all artifacts had been published correctly in obj/Docker/publish and if you run docker-compose up you will received errors like this:

Building locations.api
Step 1/6 : FROM microsoft/aspnetcore:1.1.2
 ---> bd434e635be8
Step 2/6 : ARG source
 ---> Using cache
 ---> 5bba3125fb64
Step 3/6 : WORKDIR /app
 ---> Using cache
 ---> ad806c09d936
Step 4/6 : EXPOSE 80
 ---> Using cache
 ---> b64d16951598
Step 5/6 : COPY ${source:-obj/Docker/publish} .
ERROR: Service 'locations.api' failed to build: COPY failed: stat /var/lib/docker/tmp/docker-builder316852726/obj/Docker/publish: no such file or directory

Then, run again docker-compose up and you should see a lot info in your terminal and may or not you can see this error in your terminal:

graceperiodmanager_1  | crit: GracePeriodManager.Services.ManagerService[0]
graceperiodmanager_1  |       FATAL ERROR: Database connections could not be opened: Cannot open database "Microsoft.eShopOnContainers.Services.OrderingDb" requested by the login. The login failed.

In that case, shut down the process (Ctrl + c) and run again docker-compose up and eShopOnContainers will run in your MAC. Open http://localhost:5100 for MVC or http://localhost:5104 for SPA.

Another problem I've found was related when you click in login in MVC app, I was receiving this error:

InvalidOperationException: IDX10803: Unable to obtain configuration from: 'http://10.0.75.1:5105/.well-known/openid-configuration'.

I've read a lot of about this error, in windows you can resolve turning off the firewall but in MAC even when you turn off firewall still receiving this error.

I've found this in Docker documentation https://docs.docker.com/docker-for-mac/networking/#there-is-no-docker0-bridge-on-macos

The Mac has a changing IP address (or none if you have no network access). From 17.06 onwards our recommendation is to connect to the special Mac-only DNS name docker.for.mac.localhost which will resolve to the internal IP address used by the host.

So, you have change in docker-compose.override.yml file in webmvc the IdentityUrl from this:

webmvc:
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ASPNETCORE_URLS=http://0.0.0.0:80
      - CatalogUrl=http://catalog.api
      - OrderingUrl=http://ordering.api
      - BasketUrl=http://basket.api
      - IdentityUrl=http://10.0.75.1:5105
      - MarketingUrl=http://marketing.api  #Local:  Use 10.0.75.1 in a "Docker for Windows" environment, if using "localhost" from browser. 
                                                 #Remote: Use ${ESHOP_EXTERNAL_DNS_NAME_OR_IP} if using external IP or DNS name from browser. 
      - UseCustomizationData=True
    ports:
      - "5100:80"

To this:

webmvc:
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ASPNETCORE_URLS=http://0.0.0.0:80
      - CatalogUrl=http://catalog.api
      - OrderingUrl=http://ordering.api
      - BasketUrl=http://basket.api
      - IdentityUrl=http://docker.for.mac.localhost:5105
      - MarketingUrl=http://marketing.api  #Local:  Use 10.0.75.1 in a "Docker for Windows" environment, if using "localhost" from browser. 
                                                 #Remote: Use ${ESHOP_EXTERNAL_DNS_NAME_OR_IP} if using external IP or DNS name from browser. 
      - UseCustomizationData=True
    ports:
      - "5100:80"

And following this steps I've could run eShopOnContainers in my MAC.

Cheers!

@danbarua
Copy link

to ensure you are using the lastest version of node packages such us angular-cli 1.3.0
I thought the whole point of Docker was to free us from developer workstation dependency hell? :trollface:

@alexlobanov
Copy link

Hi,

@danbarua
I had same issues with this error:
ERROR: Service '{service name}' failed to build: COPY failed:

And I had fixed this after install 5.2.0 npm as @eiximenis suggested:
npm 5.2.0 (npm install -g [email protected])

But not all services is started, for health check this services is down (all others working fine):

  1. http://webmvc/hc - status code ServiceUnavailable (503)
  2. http://webspa/hc - Exception during check: System.Net.Http.HttpRequestException
  3. http://catalog.api/hc - Exception during check: System.Net.Http.HttpRequestException

After opening http://localhost:5100/ I received this error:
CurlException: Couldn't resolve host name

@lurumad
Copy link

lurumad commented Aug 24, 2017

Hi @alexlobanov

Can you see in the terminal errors like this:

graceperiodmanager_1 | crit: GracePeriodManager.Services.ManagerService[0] graceperiodmanager_1 | FATAL ERROR: Database connections could not be opened: Cannot open database "Microsoft.eShopOnContainers.Services.OrderingDb" requested by the login. The login failed.

Try to run docker-compose up again. Works for me ;)

@CESARDELATORRE
Copy link
Collaborator

@lurumad When you say that sometimes "docker-compose -f docker-compose.ci.build.yml up" didn't run properly and you need to run it again... I wonder what errors did you get when building the bits?
Did you get similar errors to the following that happen in Windows CLI?:

dotnet/msbuild#2153
#288

I'm researching those issues with the dotnet CLI and MSBUILD team folks but I'd like to make sure if we have the same or similar issues when running from the Mac or it is a different thing.

@CESARDELATORRE
Copy link
Collaborator

Closing this issue. This scenario should be working in Mac.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants