I have a mono repo that has a multi-stage docker file and from that I’m trying to deploy two components (web service and static site).

Here is my docker file

FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /app

COPY . .
RUN dotnet tool restore

RUN dotnet restore

RUN dotnet publish src/Server -c release -o /deploy/server

RUN dotnet fable src/Client

FROM node:12 AS client
WORKDIR /app
COPY --from=build /app ./
RUN npm install
RUN npm run build

FROM mcr.microsoft.com/dotnet/runtime:5.0 AS server
WORKDIR /deploy/server
COPY --from=build /deploy/server ./
EXPOSE 80
ENTRYPOINT ["dotnet", "Server.dll"]

My webservice component works fine as the server *stage is the last stage but the static site I’m not sure how to tell App Platform to stop at *client

From what I understand you can tell docker to stop at a specific stage.

What is the best way to achieve this using App Platform?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hi @TWith2Sugars!

What I’d recommend is splitting your Dockerfiles into two, like so:

Dockerfile.server
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /app

COPY . .
RUN dotnet tool restore

RUN dotnet restore

RUN dotnet publish src/Server -c release -o /deploy/server

RUN dotnet fable src/Client

FROM mcr.microsoft.com/dotnet/runtime:5.0 AS server
WORKDIR /deploy/server
COPY --from=build /deploy/server ./
EXPOSE 80
ENTRYPOINT ["dotnet", "Server.dll"]
Dockerfile.client
FROM node:12 AS client
WORKDIR /app
COPY . .
RUN npm install
RUN npm run build

Then, you can set the dockerfile_path property on your Service component to Dockerfile.server and Dockerfile.client on your Static Site component. Make sure to set the output directory on the Static Site to /app/dist or wherever the files are generated.

You’ll need to edit your app specification directly using doctl to set the dockerfile_path field.

  • Thanks, I’ve done just that and it has worked.

    For anyone else who is using Fable/SAFE Stack this is my docker file:

    Docker.server

    FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
    WORKDIR /app
    
    COPY . .
    RUN dotnet tool restore
    
    RUN dotnet restore
    
    RUN dotnet publish src/Server -c release -o /deploy/server
    
    # final stage/image
    FROM mcr.microsoft.com/dotnet/runtime:5.0 AS server
    WORKDIR /deploy/server
    COPY --from=build /deploy/server ./
    EXPOSE 80
    ENTRYPOINT ["dotnet", "Server.dll"]
    
    

    Docker.client

    FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
    WORKDIR /app
    
    COPY . .
    RUN dotnet tool restore
    
    RUN dotnet restore
    
    RUN dotnet fable src/Client
    
    FROM node:12 AS client
    WORKDIR /app
    COPY --from=build /app ./
    RUN npm install
    RUN npm run build