I must be missing something. I followed the deployment instructions for a react app to a static s3 website bucket. I can do it just fine using a bare bones react app using create-react-app but when I use either x new react-spa or x new react-lite, and I create published build of it and copy it to S3, the page doesn’t seem to be rendering correctly and it throws a bunch of errors about ServiceStack. Is there something unique to a ServiceStack react app that needs to be factored in when deploying to a static s3 website?
This is not helpful, if you don’t provide the actual exceptions & invalid rendered output there’s no point posting about it. It just wastes time having to ask for it. Think about what it would take for you to be able to identify the issue & include all necessary context.
If you can publish the app and run it from the published folder, i.e:
I can create a new react app with create-react-app and publish it to S3 and it works, no web server needed. If data is needed you just use the fetch API to call out to a remote hosted .NET API. Is this not the case here?
I took x new vue-nuxt for a spin and I have to say I LOVE it! Exactly what we were looking for!
Now, the problem. Since I’m not well versed in Dockerfile, I can’t quite figure out how to get both a dotnet and node build going at the same time. We do this because we want to deploy to AWS ECS but I can’t get past this part.
Since the Dockerfile provided by Visual Studio only provide dotnet instructions, we getting stopped by this code in the proj file
<Target Name="OnFirstUse" BeforeTargets="Build" Condition=" !Exists('wwwroot\dist') ">
<Exec Command="node --version" ContinueOnError="true"><Output TaskParameter="ExitCode" PropertyName="ErrorCode" /></Exec>
<Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." />
We’re SO close…
Dockerfile looks like
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
COPY ["VueNuxtApp1/VueNuxtApp1.csproj", "VueNuxtApp1/"]
COPY ["VueNuxtApp1.ServiceInterface/VueNuxtApp1.ServiceInterface.csproj", "VueNuxtApp1.ServiceInterface/"]
COPY ["VueNuxtApp1.ServiceModel/VueNuxtApp1.ServiceModel.csproj", "VueNuxtApp1.ServiceModel/"]
RUN dotnet restore "VueNuxtApp1/VueNuxtApp1.csproj"
COPY . .
RUN dotnet build "VueNuxtApp1.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "VueNuxtApp1.csproj" -c Release -o /app/publish
FROM base AS final
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "VueNuxtApp1.dll"]
Which again, would normally work, but in this project case, we also need Node.
Question: Is Node only needed to do the initial build of the Vue parts? In other words, after the static content is generated and deployed to a static host, is Node needed any longer? I’m a bit confused here. I thought only the dotnet core backend was needed in production.
Ok, so that’s actually great news! Might be easier to just separate out the build process for each. Since I’m still experimenting with this, a full CI/CD isn’t necessary right now so I can just continue to manually build the Vue part locally and deploy to S3, while I CI/CD the dot net part. I’ll eventually look into making this more automated as per the referenced article.
Thanks for suggesting this template. I had never dived into Nuxt before and now that I have along with full ServiceStack sugar, it’s an amazing thing!