Skip to content

tanvirislam06/go-api-test

Repository files navigation

go-api-test

A simple Go-based API application containerized with Docker and deployable using Kubernetes.


Features

  • Developed in Go: Efficient and lightweight API application.
  • Containerized with Docker: Multi-stage build for smaller, secure images.
  • Deployed with Kubernetes: Easy scalability and management.

Prerequisites

Ensure you have the following installed:


Getting Started

1. Clone the Repository

git clone https://github.com/your-username/go-api-test.git
cd go-api-test

2. Build the Docker Image

Use the provided Dockerfile to build the Docker image:

docker build -t go-api-test:latest .

3. Run Locally with Docker

Run the application locally:

docker run -p 8080:8080 go-api-test:latest

Access the application at http://localhost:8080.


Kubernetes Deployment

1. Load the Docker Image into Kubernetes

If you are using Minikube or Docker Desktop, load the image:

minikube image load go-api-test:latest

2. Deploy the Application

Apply the Kubernetes manifest:

kubectl apply -f deployment.yaml

Verify the pod is running:

kubectl get pods

3. Access the Application

Port-forward to access the API:

kubectl port-forward deployment/go-api-test 8080:8080

Visit http://localhost:8080.

Alternatively, expose the deployment with a Kubernetes Service.


Project Structure

📦go-api-test
 ┣ 📂.vscode
 ┃ ┗ 📜launch.json
 ┣ 📂internal
 ┃ ┗ 📂user
 ┃ ┃ ┣ 📜handler.go
 ┃ ┃ ┣ 📜repository.go
 ┃ ┃ ┗ 📜service.go
 ┣ 📂pkg
 ┃ ┗ 📂routes
 ┃ ┃ ┗ 📜router.go
 ┣ 📂tests
 ┃ ┣ 📂integration
 ┃ ┃ ┣ 📜suite_test.go
 ┃ ┃ ┗ 📜user_api_test.go
 ┃ ┗ 📂mocks
 ┃ ┃ ┗ 📜user_repository_mock.go
 ┣ 📜.gitignore
 ┣ 📜Dockerfile
 ┣ 📜LICENSE
 ┣ 📜README.md
 ┣ 📜deployment.yaml
 ┣ 📜go.mod
 ┣ 📜go.sum
 ┣ 📜main.go
 ┗ 📜service.yaml

Development

1. Install Dependencies

go mod download

2. Run Locally

Run the application locally without Docker:

go run main.go

Contributing

Feel free to open issues or submit pull requests for any enhancements or bug fixes.


License

This project is licensed under the MIT License.


Contact

For questions or support, please reach out to:

About

api tests using ginkgo

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors