Skip to content

Commit

Permalink
Migrate to docker #641 - Update to 3.1, Use aspnet container for runt…
Browse files Browse the repository at this point in the history
…ime.
  • Loading branch information
HarelM committed Jan 29, 2020
1 parent 2d0c3f8 commit fc5f5e3
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 20 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.git/
.github/
.idea/
.vs/
docs/
**/bin/
**/obj/
Expand Down
26 changes: 15 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
FROM node:latest as build-node

WORKDIR /tmp
COPY ./IsraelHiking.Web/package.json ./IsraelHiking.Web/package-lock.json ./
WORKDIR /angular
COPY ./IsraelHiking.Web/ ./

RUN npm i
RUN npm i && npm run build -- --no-progress

COPY /IsraelHiking.Web/ ./
RUN npm run build -- --no-progress
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 as build-net

FROM mcr.microsoft.com/dotnet/core/sdk:3.0 as release

WORKDIR /usr/app
WORKDIR /net
COPY . .

RUN dotnet restore && dotnet build

COPY --from=build-node /tmp/wwwroot ./IsraelHiking.Web/wwwroot
WORKDIR /net/IsraelHiking.Web

RUN dotnet publish

From mcr.microsoft.com/dotnet/core/aspnet:3.1 as release

WORKDIR /israelhiking

WORKDIR /usr/app/IsraelHiking.Web
COPY --from=build-net /net/IsraelHiking.Web/bin/Debug/netcoreapp3.1/publish ./
COPY --from=build-node /angular/wwwroot ./wwwroot

CMD dotnet run --no-build --no-restore
ENTRYPOINT ["dotnet", "IsraelHiking.Web.dll"]
7 changes: 5 additions & 2 deletions IsraelHiking.Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,14 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
var rewriteOptions = new RewriteOptions();
rewriteOptions.Rules.Add(new RewriteWithQueryRule(".*_escaped_fragment_=%2F%3Fs%3D(.*)", "api/opengraph/$1", false));

if (env.IsDevelopment())
if (_isDevelopment)
{
app.UseDeveloperExceptionPage();
}
rewriteOptions.AddRedirectToHttps();
else
{
rewriteOptions.AddRedirectToHttps();
}
app.UseRewriter(rewriteOptions);

app.UseCors(builder =>
Expand Down
3 changes: 3 additions & 0 deletions IsraelHiking.Web/appsettings.Docker.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"binariesFolder": ""
}
16 changes: 9 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
version: '3.4'

services:
#website:
# image: israel-hiking
# build: .
# environment:
# - ASPNETCORE_ENVIRONMENT=Development
# ports:
# - "5000:5000"
website:
image: israel-hiking
build: .
environment:
- ASPNETCORE_ENVIRONMENT=Development
ports:
- "5000:5000"
volumes:
- ./IsraelHiking.Web/appsettings.Docker.json:/israelhiking/appsettings.json
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:5.6.16
container_name: elasticsearch
Expand Down

0 comments on commit fc5f5e3

Please sign in to comment.