forked from Kieran/void.cat
Create nospa image
This commit is contained in:
parent
727a3b97a5
commit
d82c43bb3e
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -18,3 +18,5 @@ jobs:
|
||||
- uses: docker/setup-buildx-action@v1
|
||||
- name: Build the Docker image
|
||||
run: docker buildx build -t ghcr.io/v0l/void.cat/app:latest --platform linux/amd64 --push .
|
||||
- name: Build the NoSPA Docker image
|
||||
run: docker buildx build -t ghcr.io/v0l/void.cat/api:latest -f nospa.dockerfile --platform linux/amd64 --push .
|
@ -107,7 +107,9 @@ foreach (var migration in migrations)
|
||||
await migration.Migrate();
|
||||
}
|
||||
|
||||
#if HostSPA
|
||||
app.UseStaticFiles();
|
||||
#endif
|
||||
|
||||
app.UseRouting();
|
||||
app.UseAuthentication();
|
||||
@ -117,7 +119,9 @@ app.UseEndpoints(ep =>
|
||||
{
|
||||
ep.MapControllers();
|
||||
ep.MapMetrics();
|
||||
#if HostSPA
|
||||
ep.MapFallbackToFile("index.html");
|
||||
#endif
|
||||
});
|
||||
|
||||
app.Run();
|
||||
|
@ -4,10 +4,11 @@
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UserSecretsId>126065b9-67d3-4d98-9bad-82f359a7e313</UserSecretsId>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<SpaRoot>spa\</SpaRoot>
|
||||
<DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
|
||||
<HostSPA>True</HostSPA>
|
||||
<DefineConstants Condition="'$(HostSPA)' == 'True'">$(DefineConstants);HostSPA</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@ -27,6 +28,9 @@
|
||||
<Content Include="..\Dockerfile">
|
||||
<Link>Dockerfile</Link>
|
||||
</Content>
|
||||
<Content Include="..\nospa.dockerfile">
|
||||
<Link>nospa.dockerfile</Link>
|
||||
</Content>
|
||||
<None Remove="$(SpaRoot)**" />
|
||||
<None Include="$(SpaRoot)**" Exclude="$(SpaRoot)node_modules\**" />
|
||||
</ItemGroup>
|
||||
@ -41,12 +45,12 @@
|
||||
<Exec WorkingDirectory="$(SpaRoot)" Command="npx yarn install" />
|
||||
</Target>
|
||||
|
||||
<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
|
||||
<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish" Condition="'$(HostSPA)' == 'True'">
|
||||
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
|
||||
<Exec WorkingDirectory="$(SpaRoot)" Command="npx yarn install" />
|
||||
<Exec WorkingDirectory="$(SpaRoot)" Command="npx yarn build" />
|
||||
</Target>
|
||||
<Target Name="IncludeBuildFiles" AfterTargets="PublishRunWebpack">
|
||||
<Target Name="IncludeBuildFiles" AfterTargets="PublishRunWebpack" Condition="'$(HostSPA)' == 'True'">
|
||||
<ItemGroup>
|
||||
<_CopyItems Include="$(SpaRoot)build\**\*.*" />
|
||||
</ItemGroup>
|
||||
|
@ -7,6 +7,7 @@
|
||||
"@reduxjs/toolkit": "^1.7.2",
|
||||
"feather-icons-react": "^0.5.0",
|
||||
"moment": "^2.29.1",
|
||||
"preval.macro": "^5.0.0",
|
||||
"qrcode.react": "^1.0.1",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
|
@ -1,4 +1,7 @@
|
||||
import {useSelector} from "react-redux";
|
||||
import preval from "preval.macro";
|
||||
|
||||
const ApiHost = preval`module.exports = process.env.API_HOST || '';`;
|
||||
|
||||
export function useApi() {
|
||||
const auth = useSelector(state => state.login.jwt);
|
||||
@ -14,7 +17,7 @@ export function useApi() {
|
||||
headers["Content-Type"] = "application/json";
|
||||
}
|
||||
|
||||
return await fetch(url, {
|
||||
return await fetch(`${ApiHost}${url}`, {
|
||||
method,
|
||||
headers,
|
||||
body: body ? JSON.stringify(body) : undefined
|
||||
|
@ -1511,7 +1511,7 @@
|
||||
resolved "https://registry.yarnpkg.com/@trysound/sax/-/sax-0.2.0.tgz#cccaab758af56761eb7bf37af6f03f326dd798ad"
|
||||
integrity sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA==
|
||||
|
||||
"@types/babel__core@^7.0.0", "@types/babel__core@^7.1.14":
|
||||
"@types/babel__core@^7.0.0", "@types/babel__core@^7.1.12", "@types/babel__core@^7.1.14":
|
||||
version "7.1.18"
|
||||
resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.18.tgz#1a29abcc411a9c05e2094c98f9a1b7da6cdf49f8"
|
||||
integrity sha512-S7unDjm/C7z2A2R9NzfKCK1I+BAALDtxEmsJBwlB3EzNfb929ykjL++1CK9LO++EIp2fQrC8O+BwjKvz6UeDyQ==
|
||||
@ -2374,7 +2374,7 @@ babel-plugin-jest-hoist@^27.4.0:
|
||||
"@types/babel__core" "^7.0.0"
|
||||
"@types/babel__traverse" "^7.0.6"
|
||||
|
||||
babel-plugin-macros@^3.1.0:
|
||||
babel-plugin-macros@^3.0.1, babel-plugin-macros@^3.1.0:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/babel-plugin-macros/-/babel-plugin-macros-3.1.0.tgz#9ef6dc74deb934b4db344dc973ee851d148c50c1"
|
||||
integrity sha512-Cg7TFGpIr01vOQNODXOOaGz2NpCU5gl8x1qJFbb6hbZxR7XrcE2vtbAsTAbJ7/xwJtUuJEw8K8Zr/AE0LHlesg==
|
||||
@ -2412,6 +2412,16 @@ babel-plugin-polyfill-regenerator@^0.3.0:
|
||||
dependencies:
|
||||
"@babel/helper-define-polyfill-provider" "^0.3.1"
|
||||
|
||||
babel-plugin-preval@^5.0.0:
|
||||
version "5.1.0"
|
||||
resolved "https://registry.yarnpkg.com/babel-plugin-preval/-/babel-plugin-preval-5.1.0.tgz#6efb89bf6b97af592cd1400c6df49c0e9e6ab027"
|
||||
integrity sha512-G5R+xmo5LS41A4UyZjOjV0mp9AvkuCyUOAJ6TOv/jTZS+VKh7L7HUDRcCSOb0YCM/u0fFarh7Diz0wjY8rFNFg==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.12.5"
|
||||
"@types/babel__core" "^7.1.12"
|
||||
babel-plugin-macros "^3.0.1"
|
||||
require-from-string "^2.0.2"
|
||||
|
||||
babel-plugin-transform-react-remove-prop-types@^0.4.24:
|
||||
version "0.4.24"
|
||||
resolved "https://registry.yarnpkg.com/babel-plugin-transform-react-remove-prop-types/-/babel-plugin-transform-react-remove-prop-types-0.4.24.tgz#f2edaf9b4c6a5fbe5c1d678bfb531078c1555f3a"
|
||||
@ -6699,6 +6709,13 @@ pretty-format@^27.4.6:
|
||||
ansi-styles "^5.0.0"
|
||||
react-is "^17.0.1"
|
||||
|
||||
preval.macro@^5.0.0:
|
||||
version "5.0.0"
|
||||
resolved "https://registry.yarnpkg.com/preval.macro/-/preval.macro-5.0.0.tgz#bb9e0e0cd06aee094dd84eed89851b5a7337cc2f"
|
||||
integrity sha512-+OZRqZYx1pjZ7H5Jis8bPFXkiT7lwA46UzAT4IjuzFVKwkJK+TwIx1TCqrqNCf8U3e5O12mEJEz1BXslkCLWfQ==
|
||||
dependencies:
|
||||
babel-plugin-preval "^5.0.0"
|
||||
|
||||
process-nextick-args@~2.0.0:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"
|
||||
|
14
nospa.dockerfile
Normal file
14
nospa.dockerfile
Normal file
@ -0,0 +1,14 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
|
||||
WORKDIR /app
|
||||
|
||||
# Copy everything else and build
|
||||
COPY VoidCat .
|
||||
RUN rm -rf appsettings.*.json
|
||||
RUN dotnet publish -c Release -o out -p:HostSPA=Flase VoidCat.csproj
|
||||
|
||||
# Build runtime image
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:6.0
|
||||
WORKDIR /app
|
||||
COPY --from=build-env /app/out .
|
||||
ENTRYPOINT ["dotnet", "VoidCat.dll"]
|
Loading…
Reference in New Issue
Block a user