-
Notifications
You must be signed in to change notification settings - Fork 14
containerization
The Reference Architecture API uses Docker for containerization and to support a build once run in all environments scenario.
The repository includes three (3) Docker configuration files that, collectively, support various build and deploy scenarios.
| File Name | Description |
|---|---|
./.dockerignore |
Instructs Docker to ignore files and folders when building images |
./Dockerfile |
Instructions to build docker image |
./docker-compose.yml |
Instructions to build a docker service |
There are two approaches to running the Reference Architecture API.
- Run the Reference Architecture API as a docker service, with all dependencies hosted inside Docker containers.
- Run the Reference Architecture API as a single docker image, with dependencies running on the local machine or other hosted environments.
Prior to running a docker container, we must first build a docker image.
This is a simple build. The Dockerfile assumes that the application has already been built and published into the ./publish folder.
FROM microsoft/aspnetcore:2.0
WORKDIR /app
COPY ./publish .
ENTRYPOINT ["dotnet", "Infrastructure.WebApi.dll"]The following command builds the image.
docker build -t walterpinson/reference-architecture-api .Alternatively, the ./sh/build_image.sh script can be run to achieve the same result.
The following command can be used to build and run the docker container. This command assumes certain dependencies are in place and running in the local environment, such as MongoDB.
docker run -itd -p 5001:80 \
-e ASPNETCORE_ENVIRONMENT \
-e NoteTaker__NotificationService__SendGrid__ApiKey \
-e ConnectionStrings__NoteTakingService \
--name refarch_api walterpinson/reference-architecture-apiAlternatively, the ./sh/build_container.sh bash script can be run to achieve the same result.