Skip to content

Commit 9347903

Browse files
authored
Adding a dockerfile to make it able to run as a docker container (#28)
1 parent 48133aa commit 9347903

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
2+
WORKDIR /app
3+
EXPOSE 80
4+
5+
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
6+
WORKDIR /src
7+
COPY ["./AspNetCoreVueStarter.csproj", "app/"]
8+
RUN dotnet restore "app/AspNetCoreVueStarter.csproj"
9+
COPY . .
10+
RUN apt-get update -yq
11+
RUN apt-get install curl gnupg -yq
12+
RUN curl -sL https://deb.nodesource.com/setup_13.x | bash -
13+
RUN apt-get install -y nodejs
14+
RUN dotnet build "/src/AspNetCoreVueStarter.csproj" -c Release -o /app/build
15+
16+
FROM build AS publish
17+
RUN dotnet publish "/src/AspNetCoreVueStarter.csproj" -c Release -o /app/publish
18+
19+
FROM base AS runtime
20+
WORKDIR /app
21+
COPY --from=publish /app/publish .
22+
ENTRYPOINT ["dotnet", "AspNetCoreVueStarter.dll"]

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Now application is ready to run.
8181

8282
## Run the application
8383

84-
You have two choices when it comes to how you prefer to run the app. You can either use the command line or the build-in run command.
84+
You have three choices when it comes to how you prefer to run the app. You can either use the command line or the build-in run command.
8585

8686
### 1. Using the command line
8787

@@ -93,6 +93,14 @@ You have two choices when it comes to how you prefer to run the app. You can eit
9393

9494
> It will take some time during the first run to download all client side dependencies.
9595
96+
### 3. Using docker
97+
98+
* Run the following command in a cmd window to build the docker image:
99+
`docker build -t <IMAGE_NAME> .`
100+
101+
* Run the application in a cmd window by this command:
102+
`docker run -d -p 8080:80 <IMAGE_NAME>`
103+
96104
## View your application running
97105

98106
Browse to [http://localhost:5000](http://localhost:5000) for ASP.&#8203;NET Core + Vue app or browse to [http://localhost:8080](http://localhost:8080) for Vue app only.
@@ -119,6 +127,7 @@ Special thanks to everyone who helped and contributed to this project!
119127
* [@arisliang](https://github.com/arisliang)
120128
* [@dotnetshadow](https://github.com/dotnetshadow)
121129
* [@NickStees](https://github.com/NickStees)
130+
* [@wallyjue](https://github.com/wallyjue)
122131

123132
---
124133

0 commit comments

Comments
 (0)