This document outlines the setup process and usage of the Makefile for the go-geo project.
Before running the project, you need to set up your environment variables:
-
Copy the
.env.example
file to create a new.env
file:cp .env.example .env
-
Edit the
.env
file to set your specific configuration:DB_HOST=localhost DB_PORT=5432 DB_USER=go-geo DB_PASSWORD=password DB_NAME=go-geo SERVER_PORT=8080
Adjust these values as needed for your development environment.
After setting up your environment variables, you can set up the PostgreSQL database:
-
Ensure you have Docker installed on your system.
-
Use the provided
start-postgres.sh
script to run a PostgreSQL instance:./start-postgres.sh
This script will use the environment variables from your
.env
file to configure the PostgreSQL container. -
Alternatively, you can use the Makefile command (after reviewing the Makefile section below):
make start-db
This command will start a PostgreSQL container with PostGIS, using the environment variables from your
.env
file.
Remember to stop the database when you're done:
make stop-db
The project includes a Makefile with various commands to simplify development tasks. Here's an overview of the available commands:
make start-db
: Starts a PostgreSQL container with PostGIS.make stop-db
: Stops and removes the PostgreSQL container.make migrate
: Runs database migrations.
make build
: Builds the application.make run
: Builds and runs the application.make clean
: Removes build artifacts.
make test
: Runs all tests in the project.make deps
: Downloads project dependencies.
make docs
: Generates API documentation using Swag.
make help
: Displays a list of available commands with descriptions.make all
: Cleans and builds the project.make setup
: Runs multiple commands in sequence (deps, install-swag, install-lint, migrate, docs).
Here's a typical workflow for setting up and running the project:
-
Set up the environment:
cp .env.example .env # Edit .env as needed
-
Start the database:
./start-postgres.sh # or make start-db
-
Set up the project:
make setup
-
Run the application:
make run
-
When you're done, stop the database:
make stop-db
This workflow will set up your environment, start the database, prepare the project (including generating documentation), and run the application.