After you create the package of the installable cloud app, you can create a docker image from the Web API folder. You can do this by the Dockerfile.
Docker Desktop is required to be installed on the machine in order to execute the docker commands and the Dockerfile.
To build a docker image of Web APIs from a Dockerfile:
-
Locate the Web API folder.
Let's take "salesdemo_cloud_API" as an example.
-
Create a file named "Dockerfile" in the "salesdemo_cloud_API" folder.
Add the following instructions to the Dockerfile:
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base WORKDIR /app EXPOSE 80 COPY . . ENTRYPOINT ["dotnet", "ServerAPIs.dll"]
-
The FROM instruction specifies the parent image from which you are building.
-
The WORKDIR instruction sets the working directory for the subsequent instructions such as COPY and ENTRYPOINT.
-
The COPY instruction copies files or directories to the container.
-
The ENTRYPOINT instruction configures the executable to run when the container is initiated.
For more about the Dockerfile, refer to this page.
-
-
Execute the following command to build the "salesdemo_cloud_API" folder as an image from the Dockerfile.
Docker build -f "C:\Users\appeon\AppData\Local\Temp\pbappscache\export\salesdemo_cloud\salesdemo_cloud_API\Dockerfile" -t salesdemo_serverapis:latest "C:\Users\appeon\AppData\Local\Temp\pbappscache\export\salesdemo_cloud\salesdemo_cloud_API"
-
-f points to the Dockerfile.
-
-t specifies the name and optionally a tag of the image to be created in the name:tag format. Take "salesdemo_serverapis:latest" in the above command as an example, salesdemo_serverapis is the image name, latest is the tag.
For more about the "Docker build" command, refer to this page.
-
To run the docker image:
-
Execute the following command to run the docker image as a docker container.
docker run --name="salesdemo_cloud" -d -p 5099:80 salesdemo_cloud:latest
-
--name assigns a name to the container.
-
-d runs the container in background and prints the container ID.
-
-p publishes the container's port(s) to the host.
For more about the "Docker run" command, refer to this page.
-