Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TimeKeeper.Api/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "TimeKeeper.Api v1"));
}

app.UseHttpsRedirection();
// app.UseHttpsRedirection();

app.UseRouting();

Expand Down
5 changes: 4 additions & 1 deletion TimeKeeper.Client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using MudBlazor.Services;
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Refit;
using TimeKeeper.Shared.Api;

Expand All @@ -15,8 +16,10 @@ public static async Task Main(string[] args)
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");

var apiLocation = builder.Configuration.GetValue<string>("apiLocation") ?? "https://localhost:44331/";

builder.Services.AddRefitClient<ITimeEntryApi>()
.ConfigureHttpClient(c => { c.BaseAddress = new Uri("https://localhost:44331"); });
.ConfigureHttpClient(c => { c.BaseAddress = new Uri(apiLocation); });

builder.Services.AddMudServices();

Expand Down
5 changes: 5 additions & 0 deletions TimeKeeper.Client/TimeKeeper.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
Expand All @@ -20,4 +21,8 @@
<ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" />
</ItemGroup>

<ItemGroup>
<None Remove="nginx.conf" />
</ItemGroup>

</Project>
15 changes: 15 additions & 0 deletions TimeKeeper.Client/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
events { }
http {
include mime.types;
types {
application/wasm wasm;
}
server {
listen 80;
index index.html;
location / {
root /usr/share/nginx/html;
try_files $uri $uri/ /index.html;
}
}
}
2 changes: 1 addition & 1 deletion TimeKeeper.Client/wwwroot/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"apiLocation": "https://localhost:5001"
"apiLocation": "http://localhost:5000"
}
4 changes: 2 additions & 2 deletions TimeKeeper.Shared/Shared/HostingModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public HostingModel(string uri)
{
this.uri = uri;
}
public bool IsWasm => uri.Contains("localhost:44360") || uri.Contains("localhost:5003");
public bool IsWasm => uri.Contains("localhost:44360") || uri.Contains("localhost:5003") || uri.Contains("localhost:5002");
public string Name => IsWasm ? "Client (WASM)" : "Server Side";
}
}
}
25 changes: 25 additions & 0 deletions build/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.idea
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
25 changes: 25 additions & 0 deletions build/api.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 5000
ENV ASPNETCORE_URLS=http://*:5000;

FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY TimeKeeper.Api/TimeKeeper.Api.csproj TimeKeeper.Api/

RUN dotnet restore "TimeKeeper.Api/TimeKeeper.Api.csproj"

COPY TimeKeeper.Api/. TimeKeeper.Api/.
COPY TimeKeeper.Shared/. TimeKeeper.Shared/.

COPY ["TimeKeeper.Client/.", "TimeKeeper.Client/"]
COPY ["TimeKeeper.Shared/.", "TimeKeeper.Shared/"]

WORKDIR "/src/TimeKeeper.Api"

RUN dotnet publish "TimeKeeper.Api.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=build /app .
ENTRYPOINT ["dotnet", "TimeKeeper.Api.dll"]
18 changes: 18 additions & 0 deletions build/client.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY ["TimeKeeper.Client/TimeKeeper.Client.csproj", "TimeKeeper.Client/"]
COPY ["TimeKeeper.Shared/TimeKeeper.Shared.csproj", "TimeKeeper.Shared/"]

RUN dotnet restore "TimeKeeper.Client/TimeKeeper.Client.csproj"

COPY ["TimeKeeper.Client/.", "TimeKeeper.Client/"]
COPY ["TimeKeeper.Shared/.", "TimeKeeper.Shared/"]

WORKDIR "/src/TimeKeeper.Client"

RUN dotnet publish "TimeKeeper.Client.csproj" -c Release -o /app

FROM nginx:alpine AS final
WORKDIR /usr/share/nginx/html
COPY --from=build /app/wwwroot .
COPY TimeKeeper.Client/nginx.conf /etc/nginx/nginx.conf
29 changes: 29 additions & 0 deletions build/create-db.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
CREATE DATABASE TimeKeeper;
GO
USE TimeKeeper;
GO

CREATE LOGIN TestUser WITH PASSWORD = 'T1meKeeper!';
GO
CREATE USER TestUser FOR LOGIN TestUser;
GO
ALTER SERVER ROLE sysadmin ADD MEMBER [TestUser];
GO

CREATE TABLE [dbo].[TimeEntries]
(
[Id] INT NOT NULL PRIMARY KEY IDENTITY,
[User] INT NOT NULL,
[Client] INT NOT NULL,
[Category] INT NOT NULL,
[Hours] DECIMAL NOT NULL,
[Notes] NVARCHAR(200) NOT NULL,
[IsSubmitted] BIT NOT NULL,
[IsAuthorised] BIT NOT NULL,
[AuthorisedBy] INT NULL,
[DateModified] DATETIME NULL,
[ModifiedBy] INT NULL,
[DateCreated] DATETIME NOT NULL,
[CreatedBy] INT NOT NULL
)
GO
27 changes: 27 additions & 0 deletions build/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: '3.8'

services:
db:
container_name: Timekeeper_sql_server
build:
context: ./../
dockerfile: ./build/mssqlserver.Dockerfile
ports:
- "1433:1433"
api:
container_name: Timekeeper_api
build:
context: ./../
dockerfile: ./build/api.Dockerfile
ports:
- "5000:5000"
environment:
- ConnectionStrings__DefaultConnection=Server=db;Database=TimeKeeper;MultipleActiveResultSets=true;User Id=TestUser;Password=T1meKeeper!

client:
container_name: Timekeeper_client
build:
context: ./../
dockerfile: ./build/client.Dockerfile
ports:
- "5002:80"
14 changes: 14 additions & 0 deletions build/mssqlserver.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM mcr.microsoft.com/mssql/server:2017-latest

ARG SA_PASSWORD=Password1!
ENV SA_PASSWORD=$SA_PASSWORD
ENV ACCEPT_EULA="Y"

EXPOSE 1433

RUN mkdir -p /usr/work
COPY ./build/*.sql /usr/work/

WORKDIR /usr/work
RUN ( /opt/mssql/bin/sqlservr & ) | grep -q "Service Broker manager has started" \
&& /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "$SA_PASSWORD" -i create-db.sql
1 change: 1 addition & 0 deletions runClient.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker-compose -f ./build/docker-compose.yml up -d --build
1 change: 1 addition & 0 deletions runDb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker-compose -f ./build/docker-compose.yml up -d --build db