Question

How to choose a named stage in a Docker file to use by App Platform

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?


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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.