|
| 1 | +# Docker Support JavaScriptServices |
| 2 | + |
| 3 | +Using Visual Studio 2017 you can right click each project and Add Docker Support. Visual Studio will create a Dockerfile for the project and register it in the docker-compose section of your solution. |
| 4 | +The Dockerfile created by Visual Studio looks like this: |
| 5 | +``` |
| 6 | +FROM microsoft/aspnetcore:1.1 |
| 7 | +ARG source |
| 8 | +WORKDIR /app |
| 9 | +EXPOSE 80 |
| 10 | +COPY ${source:-obj/Docker/publish} . |
| 11 | +ENTRYPOINT ["dotnet", "MusicStore.dll"] |
| 12 | +``` |
| 13 | + |
| 14 | +The problem is that JavaScriptServices needs NodeJS to run, which is not available on the microsoft/aspnetcore:1.1 image. We need to install it before starting the application. |
| 15 | +Change the Dockerfile like this: |
| 16 | +``` |
| 17 | +FROM microsoft/aspnetcore:1.1 |
| 18 | +RUN apt-get update |
| 19 | +RUN apt-get install curl |
| 20 | +RUN curl -sL https://deb.nodesource.com/setup_6.x | bash |
| 21 | +RUN apt-get install -y build-essential nodejs |
| 22 | +ARG source |
| 23 | +WORKDIR /app |
| 24 | +EXPOSE 80 |
| 25 | +COPY ${source:-obj/Docker/publish} . |
| 26 | +ENTRYPOINT ["dotnet", "MusicStore.dll"] |
| 27 | +``` |
| 28 | + |
| 29 | +Docker support was added to all sample projects. The React MusicStore is not work properly due to a webpack error. |
| 30 | + |
| 31 | +## Running with Docker |
| 32 | +To run the application inside Docker, make sure that docker-compose is the Start-up project on your solution. Then, simply press F5 which will run all configured samples in a docker container. |
| 33 | +To browse go to the command line and type: |
| 34 | +``` |
| 35 | +docker ps |
| 36 | +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
| 37 | +8da5f8ec45fe reactmusicstore:dev "tail -f /dev/null" 12 minutes ago Up 12 minutes 0.0.0.0:32779->80/tcp dockercompose3094088439_reactmusicstore_1 |
| 38 | +16593eafd06a reactgrid:dev "tail -f /dev/null" 12 minutes ago Up 12 minutes 0.0.0.0:32780->80/tcp dockercompose3094088439_reactgrid_1 |
| 39 | +7fda780decb0 ngmusicstore:dev "tail -f /dev/null" 12 minutes ago Up 12 minutes 0.0.0.0:32778->80/tcp dockercompose3094088439_ngmusicstore_1 |
| 40 | +7c0d49413df6 nodeservicesexamples:dev "tail -f /dev/null" 12 minutes ago Up 12 minutes 0.0.0.0:32777->80/tcp dockercompose3094088439_nodeservicesexamples_1 |
| 41 | +0f15ba2c085c reactgrid:dev "tail -f /dev/null" About an hour ago Up About an hour 0.0.0.0:32772->80/tcp dockercompose4052802262_reactgrid_1 |
| 42 | +``` |
| 43 | + |
| 44 | +If you open your browser on localhost:32778 you will see the Angular Music Store Sample. I've added in page footer information about the hosting environment. |
| 45 | +Under docker (at least for Windows) the footer should look like: |
| 46 | +``` |
| 47 | +Running on 7fda780decb0 (Linux 4.9.12-moby #1 SMP Tue Feb 28 12:11:36 UTC 2017) |
| 48 | +``` |
0 commit comments