Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

abp dockerize functional #21570

Open
1 task done
Vicemi opened this issue Dec 7, 2024 · 1 comment
Open
1 task done

abp dockerize functional #21570

Vicemi opened this issue Dec 7, 2024 · 1 comment

Comments

@Vicemi
Copy link

Vicemi commented Dec 7, 2024

Is there an existing article or article request for this?

  • I have searched the existing resources

Describe the article you'd like

Hi, I am currently building my own image to dockerize my projects, I have been trying for 2 weeks to create my image but I always have failures, currently this is what I have in my files and I have failures, also here I share what I usually do before anything and a screen of the error I have, if someone can help me I would appreciate it a lot.

First of all what I usually do is this:

dotnet publish src/Acme.BookStore.Web/Acme.BookStore.Web.csproj -c Release
Dockerfile:

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

ENV ASPNETCORE_URLS=http://+:80;https://+:443

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src

ENV NODE_VERSION 20.8.0
ENV YARN_VERSION 1.22.19

RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
&& apt-get update
&& apt-get install -y nodejs
&& npm install -g yarn@$YARN_VERSION

COPY ["src/Acme.BookStore.Web/Acme.BookStore.Web.csproj", "src/Acme.BookStore.Web/"]
COPY ["src/Acme.BookStore.Application/Acme.BookStore.Application.csproj", "src/Acme.BookStore.Application/"]
COPY ["src/Acme.BookStore.HttpApi/Acme.BookStore.HttpApi.csproj", "src/Acme.BookStore.HttpApi/"]
COPY ["src/Acme.BookStore.EntityFrameworkCore/Acme.BookStore.EntityFrameworkCore.csproj", "src/Acme.BookStore.EntityFrameworkCore/"]
COPY ["src/Acme.BookStore.Domain/Acme.BookStore.Domain.csproj", "src/Acme.BookStore.Domain/"]
COPY ["src/Acme.BookStore.Domain.Shared/Acme.BookStore.Domain.Shared.csproj", "src/Acme.BookStore.Domain.Shared/"]
RUN dotnet restore "src/Acme.BookStore.Web/Acme.BookStore.Web.csproj"

COPY . .
WORKDIR "/src/Acme.BookStore.Web"

RUN dotnet tool install -g Volo.Abp.Cli --version 4.4.0
&& export PATH="$PATH:/root/.dotnet/tools"
&& abp install-libs

RUN yarn install --frozen-lockfile

RUN dotnet build "Acme.BookStore.Web.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Acme.BookStore.Web.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Acme.BookStore.Web.dll"]
docker-compose.yml:

version: "3.8"
services:
app:
image: mycompanyname/abptemplate:latest
container_name: abptemplate_app
build:
context: .
dockerfile: Dockerfile
ports:

  • "7080:80"

  • "7081:443"
    environment:

  • ASPNETCORE_ENVIRONMENT=Production

  • ASPNETCORE_URLS=https://+:443

  • App__SelfUrl=https://localhost:7081/ # Ajuste para SelfUrl

  • AuthServer__Authority=https://localhost:7081/ # Ajuste para AuthServer Authority

  • ConnectionStrings__Default=Server=db;Database=BookStore;User=sa;Password=StrongPassword!123;TrustServerCertificate=true

  • StringEncryption__DefaultPassPhrase=NSmw7ZIpvm1EDbWV
    volumes:

  • ./logs:/app/logs
    depends_on:

  • db
    command: >
    bash -c "dotnet ef database update && dotnet Acme.BookStore.Web.dll"

db:
image: mcr.microsoft.com/mssql/server:2022-latest
container_name: abptemplate_db
ports:

  • "1433:1433"
    environment:
    SA_PASSWORD: "StrongPassword!123"
    ACCEPT_EULA: "Y"
    volumes:
  • db_data:/var/opt/mssql
  • ./scripts:/docker-entrypoint-initdb.d # Volumen con scripts SQL para inicializar la DB

volumes:
db_data:
Errors in build command:

docker-compose build
db uses an image, skipping
Building app
[+] Building 54.7s (21/25) docker:default
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 2.10kB 0.0s
=> [internal] load metadata for mcr.microsoft.com/dotnet/aspnet:8.0 0.2s
=> [internal] load metadata for mcr.microsoft.com/dotnet/sdk:8.0 0.2s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [build 1/15] FROM mcr.microsoft.com/dotnet/sdk:8.0@sha256:032381bcea86fa0a408af5df63a930f1ff5b03116c940a7cd744d3b648e66749 0.0s
=> [base 1/2] FROM mcr.microsoft.com/dotnet/aspnet:8.0@sha256:04f79dd7f0a27eb079c2498ca9bab729ed40b91ed393d24846d6cb505f3fe646 0.0s
=> [internal] load build context 5.0s
=> => transferring context: 2.02MB 4.8s
=> CACHED [base 2/2] WORKDIR /app 0.0s
=> CACHED [final 1/2] WORKDIR /app 0.0s
=> CACHED [build 2/15] WORKDIR /src 0.0s
=> CACHED [build 3/15] RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && apt-get update && apt-get inst 0.0s
=> CACHED [build 4/15] COPY [src/Acme.BookStore.Web/Acme.BookStore.Web.csproj, src/Acme.BookStore.Web/] 0.0s
=> CACHED [build 5/15] COPY [src/Acme.BookStore.Application/Acme.BookStore.Application.csproj, src/Acme.BookStore.Application/ 0.0s
=> CACHED [build 6/15] COPY [src/Acme.BookStore.HttpApi/Acme.BookStore.HttpApi.csproj, src/Acme.BookStore.HttpApi/] 0.0s
=> CACHED [build 7/15] COPY [src/Acme.BookStore.EntityFrameworkCore/Acme.BookStore.EntityFrameworkCore.csproj, src/Acme.BookSt 0.0s
=> CACHED [build 8/15] COPY [src/Acme.BookStore.Domain/Acme.BookStore.Domain.csproj, src/Acme.BookStore.Domain/] 0.0s
=> CACHED [build 9/15] COPY [src/Acme.BookStore.Domain.Shared/Acme.BookStore.Domain.Shared.csproj, src/Acme.BookStore.Domain.S 0.0s
=> CACHED [build 10/15] RUN dotnet restore "src/Acme.BookStore.Web/Acme.BookStore.Web.csproj" 0.0s
=> [build 11/15] COPY . . 40.1s
=> [build 12/15] WORKDIR /src/Acme.BookStore.Web 0.4s
=> ERROR [build 13/15] RUN dotnet tool install -g Volo.Abp.Cli --version 4.4.0 && export PATH="/usr/local/sbin:/usr/local/b 8.4s
[build 13/15] RUN dotnet tool install -g Volo.Abp.Cli --version 4.4.0 && export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.dotnet/tools" && abp install-libs:
8.191 Tools directory '/root/.dotnet/tools' is not currently on the PATH environment variable.
8.191 If you are using bash, you can add it to your profile by running the following command:
8.191
8.191 cat << \EOF >> ~/.bash_profile
8.191 # Add .NET Core SDK tools
8.191 export PATH="$PATH:/root/.dotnet/tools"
8.191 EOF
8.191
8.191 You can add it to the current session by running the following command:
8.191
8.191 export PATH="$PATH:/root/.dotnet/tools"
8.191
8.200 You can invoke the tool using the following command: abp
8.200 Tool 'volo.abp.cli' (version '4.4.0') was successfully installed.
8.252 You must install or update .NET to run this application.
8.252
8.252 App: /root/.dotnet/tools/abp
8.252 Architecture: x64
8.253 Framework: 'Microsoft.NETCore.App', version '5.0.0' (x64)
8.257 .NET location: /usr/share/dotnet
8.257
8.257 The following frameworks were found:
8.257 8.0.11 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]
8.257
8.257 Learn more:
8.257 https://aka.ms/dotnet/app-launch-failed
8.257
8.257 To install missing framework, download:
8.257 https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=5.0.0&arch=x64&rid=linux-x64&os=debian.12

2 warnings found (use docker --debug to expand):

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format (line 14)
LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format (line 15)
Dockerfile:36
35 | # Instalar las dependencias de ABP (usando una versión específica)
36 | >>> RUN dotnet tool install -g Volo.Abp.Cli --version 4.4.0
37 | >>> && export PATH="$PATH:/root/.dotnet/tools"
38 | >>> && abp install-libs
39 |
ERROR: failed to solve: process "/bin/sh -c dotnet tool install -g Volo.Abp.Cli --version 4.4.0 && export PATH="$PATH:/root/.dotnet/tools" && abp install-libs" did not complete successfully: exit code: 150
ERROR: Service 'app' failed to build : Build failed

@sturlath
Copy link
Contributor

sturlath commented Dec 8, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants