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 install
This command initializes the Go module and updates dependencies, preparing your development environment.
To build the application binary:
make build
This 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 .env
Next, configure the variables in the .env
file according to your setup.
To run the compiled application:
make run
This command builds (if necessary) and runs the application binary.
To start the PostgreSQL database in a Docker container:
make db-up
This command uses Docker Compose to start a PostgreSQL instance as specified in docker-compose.yml
.
To stop and remove the PostgreSQL container:
make db-down
To build a Docker image for the application:
make docker-build
This builds the Docker image tagged as gas-meter
, following the instructions in the Dockerfile
.
To run the application using Docker Compose:
make docker-run
This 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 clean
This 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