Skip to content

Commit 0e7438d

Browse files
authored
Merge pull request #613 from EduardoSantanaSeverino/master
Please consider this PR, to help to update the project Docker files.
2 parents 2400d38 + 8b8af3c commit 0e7438d

File tree

11 files changed

+202
-78
lines changed

11 files changed

+202
-78
lines changed

angular/.dockerignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.env
2+
.git
3+
.gitignore
4+
.vs
5+
.vscode
6+
*/bin
7+
*/obj
8+
*/node_modules
9+
*/dist
10+
*/.git
11+
*/.idea
12+
*/.vs
13+
*/.vscode
14+
**/.toolstarget

angular/Dockerfile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# stage 1
2+
FROM node:14 as node
3+
WORKDIR /app
4+
COPY . .
5+
# This is a workaround to avoid updating appconfig.production.json file.
6+
# If you prefer to updating appconfig.production.json file instead of appconfig.container.json please delete this line.
7+
RUN mv ./src/assets/appconfig.container.json ./src/assets/appconfig.production.json
8+
RUN yarn install
9+
RUN yarn run ng build --configuration production
10+
# stage 2
111
FROM nginx
2-
3-
COPY . /usr/share/nginx/html
12+
COPY --from=node /app/dist /usr/share/nginx/html
13+
COPY fast-nginx-default.conf /etc/nginx/conf.d/default.conf

angular/fast-nginx-default.conf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
server {
2+
listen 80;
3+
sendfile on;
4+
default_type application/octet-stream;
5+
6+
gzip on;
7+
gzip_http_version 1.1;
8+
gzip_disable "MSIE [1-6]\.";
9+
gzip_min_length 256;
10+
gzip_vary on;
11+
gzip_proxied expired no-cache no-store private auth;
12+
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
13+
gzip_comp_level 9;
14+
15+
root /usr/share/nginx/html;
16+
17+
location / {
18+
try_files $uri $uri/ /index.html =404;
19+
}
20+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"remoteServiceBaseUrl": "http://localhost:44311",
3+
"appBaseUrl": "http://localhost:4200",
4+
"localeMappings": [
5+
{
6+
"from": "pt-BR",
7+
"to": "pt"
8+
},
9+
{
10+
"from": "zh-CN",
11+
"to": "zh"
12+
},
13+
{
14+
"from": "he-IL",
15+
"to": "he"
16+
}
17+
]
18+
}

aspnet-core/.dockerignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
**/.classpath
2+
**/.dockerignore
3+
**/.env
4+
**/.git
5+
**/.gitignore
6+
**/.project
7+
**/.settings
8+
**/.toolstarget
9+
**/.vs
10+
**/.vscode
11+
**/*.*proj.user
12+
**/*.dbmdl
13+
**/*.jfm
14+
**/azds.yaml
15+
**/bin
16+
**/charts
17+
**/docker-compose*
18+
**/Dockerfile*
19+
**/node_modules
20+
**/npm-debug.log
21+
**/obj
22+
**/secrets.dev.yaml
23+
**/values.dev.yaml
24+
LICENSE
25+
README.md

aspnet-core/Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
2+
3+
WORKDIR /src
4+
COPY ["src/AbpCompanyName.AbpProjectName.Web.Host/AbpCompanyName.AbpProjectName.Web.Host.csproj", "src/AbpCompanyName.AbpProjectName.Web.Host/"]
5+
COPY ["src/AbpCompanyName.AbpProjectName.Web.Core/AbpCompanyName.AbpProjectName.Web.Core.csproj", "src/AbpCompanyName.AbpProjectName.Web.Core/"]
6+
COPY ["src/AbpCompanyName.AbpProjectName.Application/AbpCompanyName.AbpProjectName.Application.csproj", "src/AbpCompanyName.AbpProjectName.Application/"]
7+
COPY ["src/AbpCompanyName.AbpProjectName.Core/AbpCompanyName.AbpProjectName.Core.csproj", "src/AbpCompanyName.AbpProjectName.Core/"]
8+
COPY ["src/AbpCompanyName.AbpProjectName.EntityFrameworkCore/AbpCompanyName.AbpProjectName.EntityFrameworkCore.csproj", "src/AbpCompanyName.AbpProjectName.EntityFrameworkCore/"]
9+
WORKDIR "/src/src/AbpCompanyName.AbpProjectName.Web.Host"
10+
RUN dotnet restore
11+
12+
WORKDIR /src
13+
COPY ["src/AbpCompanyName.AbpProjectName.Web.Host", "src/AbpCompanyName.AbpProjectName.Web.Host"]
14+
COPY ["src/AbpCompanyName.AbpProjectName.Web.Core", "src/AbpCompanyName.AbpProjectName.Web.Core"]
15+
COPY ["src/AbpCompanyName.AbpProjectName.Application", "src/AbpCompanyName.AbpProjectName.Application"]
16+
COPY ["src/AbpCompanyName.AbpProjectName.Core", "src/AbpCompanyName.AbpProjectName.Core"]
17+
COPY ["src/AbpCompanyName.AbpProjectName.EntityFrameworkCore", "src/AbpCompanyName.AbpProjectName.EntityFrameworkCore"]
18+
WORKDIR "/src/src/AbpCompanyName.AbpProjectName.Web.Host"
19+
RUN dotnet publish -c Release -o /publish --no-restore
20+
21+
FROM mcr.microsoft.com/dotnet/aspnet:6.0
22+
EXPOSE 80
23+
WORKDIR /app
24+
COPY --from=build /publish .
25+
ENTRYPOINT ["dotnet", "AbpCompanyName.AbpProjectName.Web.Host.dll"]

aspnet-core/build/build-with-ng.ps1

Lines changed: 33 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,33 @@
1-
# COMMON PATHS
2-
3-
$buildFolder = (Get-Item -Path "./" -Verbose).FullName
4-
$slnFolder = Join-Path $buildFolder "../"
5-
$outputFolder = Join-Path $buildFolder "outputs"
6-
$webHostFolder = Join-Path $slnFolder "src/AbpCompanyName.AbpProjectName.Web.Host"
7-
$ngFolder = Join-Path $buildFolder "../../angular"
8-
9-
## CLEAR ######################################################################
10-
11-
Remove-Item $outputFolder -Force -Recurse -ErrorAction Ignore
12-
New-Item -Path $outputFolder -ItemType Directory
13-
14-
## RESTORE NUGET PACKAGES #####################################################
15-
16-
Set-Location $slnFolder
17-
dotnet restore
18-
19-
## PUBLISH WEB HOST PROJECT ###################################################
20-
21-
Set-Location $webHostFolder
22-
dotnet publish --output (Join-Path $outputFolder "Host")
23-
24-
## PUBLISH ANGULAR UI PROJECT #################################################
25-
26-
Set-Location $ngFolder
27-
& yarn
28-
& ng build --prod
29-
Copy-Item (Join-Path $ngFolder "dist") (Join-Path $outputFolder "ng") -Recurse
30-
Copy-Item (Join-Path $ngFolder "Dockerfile") (Join-Path $outputFolder "ng")
31-
32-
# Change UI configuration
33-
$ngConfigPath = Join-Path $outputFolder "ng/assets/appconfig.json"
34-
(Get-Content $ngConfigPath) -replace "44311", "9901" | Set-Content $ngConfigPath
35-
(Get-Content $ngConfigPath) -replace "4200", "9902" | Set-Content $ngConfigPath
36-
37-
## CREATE DOCKER IMAGES #######################################################
38-
39-
# Host
40-
Set-Location (Join-Path $outputFolder "Host")
41-
42-
docker rmi abp/host -f
43-
docker build -t abp/host .
44-
45-
# Angular UI
46-
Set-Location (Join-Path $outputFolder "ng")
47-
48-
docker rmi abp/ng -f
49-
docker build -t abp/ng .
50-
51-
## DOCKER COMPOSE FILES #######################################################
52-
53-
Copy-Item (Join-Path $slnFolder "docker/ng/*.*") $outputFolder
54-
55-
## FINALIZE ###################################################################
56-
57-
Set-Location $outputFolder
1+
echo " Welcome to docker build"
2+
echo ""
3+
echo ""
4+
5+
$ABP_HOST="abp/host"
6+
$ABP_NG="abp/ng"
7+
8+
cd ..
9+
echo " Building docker image $ABP_HOST..."
10+
docker build -t $ABP_HOST .
11+
echo " Done. -- Building docker image $ABP_HOST..."
12+
echo ""
13+
echo ""
14+
15+
# echo " Pushing docker image $ABP_HOST..."
16+
# docker push $ABP_HOST
17+
# echo " Done. -- Pushing docker image $ABP_HOST..."
18+
# echo ""
19+
# echo ""
20+
21+
cd ..
22+
cd angular/
23+
echo " Building docker image $ABP_NG..."
24+
docker build -t $ABP_NG -f Dockerfile .
25+
echo " Done. -- Building docker image $ABP_NG..."
26+
echo ""
27+
echo ""
28+
29+
# echo " Pushing docker image $ABP_NG..."
30+
# docker push $ABP_NG
31+
# echo " Done. -- Pushing docker image $ABP_NG..."
32+
# echo ""
33+
# echo ""

aspnet-core/build/build-with-ng.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
echo " Welcome to docker build"
3+
echo ""
4+
echo ""
5+
6+
ABP_HOST="abp/host"
7+
ABP_NG="abp/ng"
8+
9+
cd ..
10+
echo " Building docker image $ABP_HOST..."
11+
docker build -t $ABP_HOST .
12+
echo " Done. -- Building docker image $ABP_HOST..."
13+
echo ""
14+
echo ""
15+
16+
# echo " Pushing docker image $ABP_HOST..."
17+
# docker push $ABP_HOST
18+
# echo " Done. -- Pushing docker image $ABP_HOST..."
19+
# echo ""
20+
# echo ""
21+
22+
cd ..
23+
cd angular/
24+
echo " Building docker image $ABP_NG..."
25+
docker build -t $ABP_NG -f Dockerfile .
26+
echo " Done. -- Building docker image $ABP_NG..."
27+
echo ""
28+
echo ""
29+
30+
# echo " Pushing docker image $ABP_NG..."
31+
# docker push $ABP_NG
32+
# echo " Done. -- Pushing docker image $ABP_NG..."
33+
# echo ""
34+
# echo ""

aspnet-core/docker/ng/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Host-Logs/
Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
1-
version: '2'
1+
version: '3'
22

33
services:
44

5-
abp_host:
6-
image: abp/host
7-
environment:
8-
- ASPNETCORE_ENVIRONMENT=Staging
9-
ports:
10-
- "9901:80"
11-
volumes:
12-
- "./Host-Logs:/app/App_Data/Logs"
5+
abp_host:
6+
image: abp/host
7+
environment:
8+
ASPNETCORE_ENVIRONMENT: "Staging"
9+
ConnectionStrings__Default: "Server=10.0.75.1; Database=AbpProjectNameDb; User=AbpProjectNameUser; Password=YourStrongPassword;"
10+
App__ServerRootAddress: "http://localhost:44311/"
11+
App__ClientRootAddress: "http://localhost:4200/"
12+
App__CorsOrigins: "http://localhost:4200"
13+
TZ: "America/Toronto"
14+
Kestrel__Endpoints__Http__Url: "http://+:80"
15+
ports:
16+
- "44311:80"
17+
volumes:
18+
- "./Host-Logs:/app/App_Data/Logs"
19+
restart: always
1320

14-
abp_ng:
15-
image: abp/ng
16-
ports:
17-
- "9902:80"
21+
abp_ng:
22+
image: abp/ng
23+
ports:
24+
- "4200:80"

0 commit comments

Comments
 (0)