The [gotemplate] Application is a GoLang service designed to run as a background service, interacting with a PostgreSQL database to manage and store data. This README outlines the commands available for building, running, and managing both the application and its database.
- Docker and Docker Compose
- GoLang environment and make (for local development)
- PostgreSQL client tools (optional, for direct database access)
- dotenv for running out of docker with make (optional)
Before running the application, ensure all dependencies are installed:
make installThis command initializes the Go module and updates dependencies, preparing your development environment.
To build the application binary:
make buildThis compiles the Go application and places the binary in the ./bin directory.
First, copy the example environment file to create your own .env file:
cp env.example .envNext, configure the variables in the .env file according to your setup.
To run the compiled application:
make runThis command builds (if necessary) and runs the application binary.
To start the PostgreSQL database in a Docker container:
make db-upThis command uses Docker Compose to start a PostgreSQL instance as specified in docker-compose.yml.
To stop and remove the PostgreSQL container:
make db-downTo build a Docker image for the application:
make docker-buildThis builds the Docker image tagged as gas-meter, following the instructions in the Dockerfile.
To run the application using Docker Compose:
make docker-runThis command builds the Docker image (if not up-to-date) and starts both the application and PostgreSQL database as defined in docker-compose.yml. The application is accessible at http://localhost:8080.
To remove build artifacts and clean up the development environment:
make cleanThis removes the ./bin directory and its contents.
If you need to access the PostgreSQL database directly, use the psql command-line tool or any PostgreSQL client, connecting with the credentials defined in your .env file and docker-compose.yml.
This project may include scripts designed for testing and engaging with its modules and dependencies. To run the example script, or any future scripts added, please use the following command as a guide: For example
go run cmd/scripts/script.go