go-crud-api

command module
v0.0.0-...-630c2ba Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2025 License: MIT Imports: 8 Imported by: 0

README

GO CRUD REST API

Go CRUD REST API Logo

GoDoc Supported Go Versions Docker Made with Gin PostgreSQL Supported Go Migration Supported GORM Supported Make Supported License

Overview

This branch introduces containerization to the REST API. By using Docker, the API is portable, easier to deploy, and follows best practices for modern application development.

Features of Containerization

  • Multi-stage Dockerfile for optimized build and runtime.
  • Environment variables injection at runtime.
  • Semantic version tagging for Docker images.
  • Reduced image size for efficient deployment.

Prerequisites

Ensure the following are installed:

  • Docker
  • Make

Building and Running with Docker

1. Build the Docker Image

Build a versioned Docker image using the Makefile:

make docker-build VERSION=<your_version>

For example:

make docker-build VERSION=1.0.0
2. Run the Docker Container

Run the API in a container:

make docker-run VERSION=<your_version>

For example:

make docker-run VERSION=1.0.0

This command uses the .env file to inject environment variables into the container.

3. Stop the Docker Container

Stop the running container:

make docker-stop
4. Push Docker Image

Push the tagged image to a container registry:

make docker-push VERSION=<your_version>

Ensure you are logged in to your container registry before running this command.

Multi-Stage Dockerfile

The multi-stage Dockerfile ensures:

  • A smaller final image size by separating build and runtime stages.
  • Faster builds and easier debugging.
  • Security by excluding development tools and files from the runtime image.

Updated Makefile Commands

Command Description
docker-build Build a Docker image.
docker-run Run the application in a Docker container.
docker-push Push the Docker image to a container registry.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
handlers/student_handler.go
handlers/student_handler.go
repository/application_repository.go
repository/application_repository.go
api
service/student_service.go
service/student_service.go

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL