Skip to content

Latest commit

 

History

History
265 lines (205 loc) · 12.3 KB

readme-docker-go.md

File metadata and controls

265 lines (205 loc) · 12.3 KB

DOCKER-GS-PING

Containerize, Scale, and Thrive with Ease!

license last-commit repo-top-language repo-language-count

_Built with:_

Go Docker GitHub%20Actions


🔗 Table of Contents

I. 📍 Overview II. 👾 Features III. 📁 Project Structure IV. 🚀 Getting Started V. 📌 Project Roadmap VI. 🔰 Contributing VII. 🎗 License VIII. 🙌 Acknowledgments


📍 Overview

docker-gs-ping is a project that simplifies deploying a Go application in a Docker container. It offers easy scalability and efficient testing. Ideal for developers seeking streamlined containerized application deployment.


👾 Features

Feature Summary
⚙️ Architecture
  • Uses a multi-stage Docker process for building, testing, and deploying the application
  • Implements an HTTP server using the Echo framework with middleware for logging and recovery
  • Follows a modular structure with defined routes for root and health endpoints
🔩 Code Quality
  • Defines project dependencies and versions in the go.mod file for proper package management
  • Includes unit tests in main_test.go to ensure code correctness
  • Follows best practices for Go programming, such as error handling and code readability
📄 Documentation
  • Provides detailed documentation for installation, usage, and testing using go modules and docker
  • Includes usage commands for running the application locally with go run or docker run
  • Offers test commands for running tests using go test
🔌 Integrations
  • Automates Docker image release to Docker Hub using GitHub Actions in the ci-cd.yml workflow
  • Automates smoke testing with the ci-smoketest.yml workflow for every push or manual trigger
  • Ensures secure handling of Docker image metadata, caching, build, test, login, and push operations
🧩 Modularity
  • Organizes codebase into separate files like main.go and main_test.go for better maintainability
  • Utilizes middleware and routing to achieve separation of concerns
  • Encourages code reusability through functions like finding the minimum of two integers
🧪 Testing
  • Includes unit tests in main_test.go to verify the correctness of functions like IntMin
  • Uses go test command for running tests across the codebase
  • Ensures code stability and reliability through comprehensive test coverage
⚡️ Performance
  • Optimizes performance by exposing port 8080 for runtime communication
  • Utilizes non-root user setup in the multi-stage Docker process for enhanced security and efficiency
  • Follows best practices for Go application performance tuning
🛡️ Security
  • Implements a non-root user setup in the Dockerfile for enhanced container security
  • Follows security best practices for Go applications, such as input validation and secure error handling
  • Ensures secure handling of Docker image operations in the CI/CD workflows

📁 Project Structure

└── docker-gs-ping/
    ├── .github
    │   └── workflows
    │       ├── ci-cd.yml
    │       └── ci-smoketest.yml
    ├── Dockerfile
    ├── Dockerfile.multistage
    ├── LICENSE
    ├── README.md
    ├── go.mod
    ├── go.sum
    ├── main.go
    └── main_test.go

📂 Project Index

DOCKER-GS-PING/
__root__
go.mod Define project dependencies and versions using the go.mod file, ensuring proper package management and compatibility within the codebase architecture.
Dockerfile - Facilitates building and running a Go application in a Docker container
- Downloads Go modules, copies source code, builds the application, and exposes port 8080 for runtime communication
- Allows easy deployment and scaling of the application within a containerized environment.
go.sum Manage project dependencies and versions using the provided go.sum file, ensuring compatibility and stability across the codebase architecture.
Dockerfile.multistage - Builds, tests, and deploys a Go application in a multi-stage Docker process
- Fetches dependencies, compiles the application, runs tests, and packages it into a minimal container image
- The resulting image exposes port 8080 and runs the application as a non-root user.
main.go - Implements a basic HTTP server using the Echo framework with middleware for logging and recovery
- Defines routes for root and health endpoints
- Retrieves the port from the environment variable or defaults to 8080
- Starts the server on the specified port
- Includes a function for finding the minimum of two integers.
main_test.go - Unit tests in main_test.go verify the correctness of the IntMin function through basic and table-driven scenarios
- These tests ensure that the function accurately determines the minimum value between two integers.
.github
workflows
ci-cd.yml - Automates Docker image release to Docker Hub based on successful tests, following a CI/CD workflow triggered by pushes to the main branch or version tags
- Handles Docker image metadata, caching, build, test, login, and push operations securely using GitHub Actions.
ci-smoketest.yml - Automates smoke testing for the project by building and testing Go code on every push or manual trigger
- Uses GitHub Actions to streamline the process in the CI pipeline.

🚀 Getting Started

☑️ Prerequisites

Before getting started with docker-gs-ping, ensure your runtime environment meets the following requirements:

  • Programming Language: Go
  • Package Manager: Go modules
  • Container Runtime: Docker

⚙️ Installation

Install docker-gs-ping using one of the following methods:

Build from source:

  1. Clone the docker-gs-ping repository:
❯ git clone https://github.com/olliefr/docker-gs-ping
  1. Navigate to the project directory:
cd docker-gs-ping
  1. Install the project dependencies:

Using go modules  

❯ go build

Using docker  

❯ docker build -t olliefr/docker-gs-ping .

🤖 Usage

Run docker-gs-ping using the following command: Using go modules  

❯ go run {entrypoint}

Using docker  

❯ docker run -it {image_name}

🧪 Testing

Run the test suite using the following command: Using go modules  

❯ go test ./...

📌 Project Roadmap

  • Task 1: Implement feature one.
  • Task 2: Implement feature two.
  • Task 3: Implement feature three.

🔰 Contributing

Contributing Guidelines
  1. Fork the Repository: Start by forking the project repository to your github account.
  2. Clone Locally: Clone the forked repository to your local machine using a git client.
    git clone https://github.com/olliefr/docker-gs-ping
  3. Create a New Branch: Always work on a new branch, giving it a descriptive name.
    git checkout -b new-feature-x
  4. Make Your Changes: Develop and test your changes locally.
  5. Commit Your Changes: Commit with a clear message describing your updates.
    git commit -m 'Implemented new feature x.'
  6. Push to github: Push the changes to your forked repository.
    git push origin new-feature-x
  7. Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.
  8. Review: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!
Contributor Graph


🎗 License

This project is protected under the SELECT-A-LICENSE License. For more details, refer to the LICENSE file.


🙌 Acknowledgments

  • List any resources, contributors, inspiration, etc. here.