Welcome to the Lotof ATrace Gateway project! This project provides a structure to generate, build, and run a GraphQL server using gqlgen and Docker for containerization. Below you'll find a comprehensive guide to get started with this project.
Before you begin, ensure you have the following installed on your machine:
- Go (version 1.23 or later)
- Docker
- Docker Compose
The project uses a Makefile to automate common tasks. Below are the available make targets and their functionalities:
- Description: Generates the necessary Go files for gqlgen, gRPC, and runs the server.
- Commands:
- Executes the
gqlgen
andgrpcgen
targets. - Starts the server using
make run
.
- Executes the
- Description: Generates the Go code required for your GraphQL server.
- Commands:
- Executes
$(GQLGEN) generate
to generate GraphQL server code. - Cleans up dependencies with
go mod tidy
.
- Executes
- Description: Generates Go stubs for gRPC services.
- Commands:
- Uses
$(PROTOC)
with pluginsprotoc-gen-go
andprotoc-gen-go-grpc
. - Places the generated files in
./internal/core/grpc/generated
.
- Uses
- Description: Runs the GraphQL server.
- Commands:
- Executes
go run ./cmd/server/main.go
to start the server.
- Executes
- Description: Builds a Docker image for the development environment.
- Commands:
- Builds Docker image using
dev.dockerfile
and names itgateway-dev
.
- Builds Docker image using
- Description: Builds a Docker image for the production environment.
- Commands:
- Builds Docker image using
main.dockerfile
and names itgateway-prod
.
- Builds Docker image using
- Description: Starts the services defined in
docker-compose.yml
. - Commands:
- Runs
$(DOCKER_COMPOSE) up -d
to start services in detached mode.
- Runs
- Description: Stops and removes the services defined in
docker-compose.yml
. - Commands:
- Runs
$(DOCKER_COMPOSE) down
to stop the services.
- Runs
- Description: Cleans up generated files.
- Commands:
- Removes the files in
internal/core/grpc/generated
and GraphQL-related generated files.
- Removes the files in
-
Clone the repository:
git clone https://github.com/pieceowater-dev/lotof.atrace.gtw.git cd lotof.atrace.gtw
-
Install dependencies:
go mod tidy
-
Generate GraphQL files and start the server:
make all
-
(Optional) To build Docker images for development or production:
make build
-
(Optional) To manage Docker services:
make compose-up # Start services make compose-down # Stop services
- Customize
Dockerfile
as needed for your project's specific requirements. - The server entry point is at
./cmd/server/main.go
.
This project is licensed under the MIT License - see the LICENSE file for details.