A simple .NET API with GitHub Actions CI/CD pipeline that automatically builds and pushes Docker images to Docker Hub.
-
Pull the image from Docker Hub:
docker pull amiromumi/dockerized-dotnetapi-cicd:latest
-
Run the Docker container:
docker run -d -p 2503:80 --name mydockerapi-container-cicd amiromumi/dockerized-dotnetapi-cicd
-
Access the API:
- Open your browser and go to: http://localhost:2503
- For environment check, visit: http://localhost:2503/env
This project includes a GitHub Actions workflow that:
- Builds the Docker image on every push to the
masterbranch. - Automatically pushes the image to Docker Hub using your credentials.
Workflow file path:
.github/workflows/ci-dockerized-dotnet-api.yml
By default, the API runs in Production mode inside the Docker container.
You can override this by passing an environment variable:
docker run -d -p 2503:80 -e ASPNETCORE_ENVIRONMENT=Development --name mydockerapi-container-cicd amiromumi/dockerized-dotnetapi-cicdCheck environment by visiting:
The application logs are stored inside the container:
- Path:
/app/logs/log.txt - Automatically creates the folder if it doesn't exist
CI-CD-DotNetAPI/
│-- .github/
│ └── workflows/
│ └── ci-dockerized-dotnet-api.yml
│-- Dockerfile
│-- Dockerized-DotNetAPI.csproj
│-- Program.cs
│-- logs/ (generated at runtime)
- Demonstrates CI/CD using GitHub Actions with Docker Hub integration.
- Supports both manual Docker CLI execution and automated image builds.
- Make sure Docker is installed and the container port is available.