I am trying to run asp.net core with spa on docker however the asp.net core image doesn't contain node if we can have official support from MS which would be great and I found a lot of people are having issues with that.
I am using the docker project which is docker compose to launch multiple componets and one of them is a spa website under asp.net core. I found the docker project will just map the volume so it wont actually run the whole dockerfile steps. The issue is obviously that we cant run npm tasks in that docker image. During development i want to serve the spa via npm run serve as it will be much faster. If we have a asp.net core + nodejs docker image then all the problems will be resovled without work around. And I believe a lot of people wanting to have this image officially supported.
Thanks for contacting us, @ldsenow .
We actually try to keep the list of the templates we own very little, while doing our best to enable community to create templates they're interested in.
@danroth27 leaving this up to you to consider.
Couldn't you have something like
RUN apt-get update -yq \
&& apt-get install curl gnupg -yq \
&& curl -sL https://deb.nodesource.com/setup_10.x | bash \
&& apt-get install nodejs -yq
in your Dockerfile?
In order to use e.g. multi-stage builds, one would have to manually call npm install and whatever building of the SPA in the Dockerfile - then copy the dist folder to the .NET Core stage of the build and publish?
Couldn't you have something like
RUN apt-get update -yq \ && apt-get install curl gnupg -yq \ && curl -sL https://deb.nodesource.com/setup_10.x | bash \ && apt-get install nodejs -yqin your Dockerfile?
This won't work for alpine-based image
I managed to resolve this with the help of a stack overflow posting (I lost it so cannot reference here. Do the following:
Put this at the top of the dockerfile:
FROM node:latest AS node_base
RUN echo "NODE Version:" && node --version
RUN echo "NPM Version:" && npm --version
Then after every FROM mcr.microsoft.com/dotnet ...etc make the next line this:
COPY --from=node_base . .
I'm using buster-slim and think (or hope) that this should work for at least Debian/Ubuntu images.
Most helpful comment
I managed to resolve this with the help of a stack overflow posting (I lost it so cannot reference here. Do the following:
Put this at the top of the dockerfile:
Then after every
FROM mcr.microsoft.com/dotnet ...etcmake the next line this:I'm using buster-slim and think (or hope) that this should work for at least Debian/Ubuntu images.