Deploying a .NET Aspire project’s apphost to a docker container

I am trying to deploy a .NET Aspire project to a docker container. I used docker init to create a dockerfile and a docker compose but when I try running docker compose up –build it says it didn’t find an Aspire workload installed. I tried adding a command to install the workload, but now when I run the publish command it doesn’t create the output folder.

Dockerfile

# syntax=docker/dockerfile:1

# Comments are provided throughout this file to help you get started.
# If you need more help, visit the Dockerfile reference guide at
# https://docs.docker.com/go/dockerfile-reference/

# Want to help us make this template better? Share your feedback here: https://forms.gle/ybq9Krt8jtBL3iCk7

################################################################################

# Learn about building .NET container images:
# https://github.com/dotnet/dotnet-docker/blob/main/samples/README.md

# Create a stage for building the application.
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build

COPY . /source

WORKDIR /source/Catalog.AppHost

# This is the architecture you’re building for, which is passed in by the builder.
# Placing it here allows the previous steps to be cached across architectures.
ARG TARGETARCH

# Build the application.
# Leverage a cache mount to /root/.nuget/packages so that subsequent builds don't have to re-download packages.
# If TARGETARCH is "amd64", replace it with "x64" - "x64" is .NET's canonical name for this and "amd64" doesn't
#   work in .NET 6.0.
RUN dotnet workload install aspire && 
    dotnet restore
RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages 
    dotnet publish -a ${TARGETARCH/amd64/x64} -c Debug --use-current-runtime --self-contained false -o /app && 
    ls -al && ls ../ -al && ls ../../ -al

# If you need to enable globalization and time zones:
# https://github.com/dotnet/dotnet-docker/blob/main/samples/enable-globalization.md
################################################################################
# Create a new stage for running the application that contains the minimal
# runtime dependencies for the application. This often uses a different base
# image from the build stage where the necessary files are copied from the build
# stage.
#
# The example below uses an aspnet alpine image as the foundation for running the app.
# It will also use whatever happens to be the most recent version of that tag when you
# build your Dockerfile. If reproducability is important, consider using a more specific
# version (e.g., aspnet:7.0.10-alpine-3.18),
# or SHA (e.g., mcr.microsoft.com/dotnet/aspnet@sha256:f3d99f54d504a21d38e4cc2f13ff47d67235efeeb85c109d3d1ff1808b38d034).
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS final
WORKDIR /app

# Copy everything needed to run the app from the "build" stage.
COPY --from=build /app .

# Switch to a non-privileged user (defined in the base image) that the app will run under.
# See https://docs.docker.com/go/dockerfile-user-best-practices/
# and https://github.com/dotnet/dotnet-docker/discussions/4764
USER $APP_UID

ENTRYPOINT ["dotnet", "Catalog.AppHost.dll"]

docker-compose

services:
  server:
    build:
      context: .
      target: final
    ports:
      - 8080:8080

The error:

docker compose up --build
[+] Building 4.1s (16/16) FINISHED                                                                                                            docker:desktop-linux
 => [server internal] load build definition from Dockerfile                                                                                                   0.0s
 => => transferring dockerfile: 2.80kB                                                                                                                        0.0s
 => [server] resolve image config for docker-image://docker.io/docker/dockerfile:1                                                                            1.0s
 => [server auth] docker/dockerfile:pull token for registry-1.docker.io                                                                                       0.0s
 => CACHED [server] docker-image://docker.io/docker/dockerfile:1@sha256:fe40cf4e92cd0c467be2cfc30657a680ae2398318afd50b0c80585784c604f28                      0.0s
 => [server internal] load metadata for mcr.microsoft.com/dotnet/sdk:8.0-alpine                                                                               0.4s
 => [server internal] load metadata for mcr.microsoft.com/dotnet/aspnet:8.0-alpine                                                                            0.4s
 => [server internal] load .dockerignore                                                                                                                      0.0s
 => => transferring context: 647B                                                                                                                             0.0s
 => [server internal] load build context                                                                                                                      0.0s
 => => transferring context: 2.73kB                                                                                                                           0.0s
 => [server build 1/5] FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine@sha256:6e8997576d16a6d7b4e6ba7ac0956d3ae46cb7a376581c40eabd20fbc5c28b8d                   0.0s
 => [server final 1/3] FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine@sha256:e22d879fb9a0fba3b2a6b15c88f005192c239e189061534c86643347b4630140                0.0s
 => CACHED [server build 2/5] COPY . /source                                                                                                                  0.0s
 => CACHED [server build 3/5] WORKDIR /source/Catalog.AppHost                                                                                                 0.0s
 => CACHED [server build 4/5] RUN dotnet workload install aspire &&     dotnet restore                                                                        0.0s
 => [server build 5/5] RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages     dotnet publish -a x64 -c Testing --use-current-runtime --self-contai  2.1s
 => CACHED [server final 2/3] WORKDIR /app                                                                                                                    0.0s
 => ERROR [server final 3/3] COPY --from=build /app .                                                                                                         0.0s
------
 > [server final 3/3] COPY --from=build /app .:
------
failed to solve: failed to compute cache key: failed to calculate checksum of ref b9d56e54-9eee-48c5-b9a6-71b47c1d6335::lymdtg8e61phx9dtukafwjrl7: "/app": not found

I tried checking to see if a folder is actually created but if I run ls on all the directories that could contain it, it doesn’t appear anywhere.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật