This is a small demo web application built with Go language that demonstrates the use of Postgres database with Go. The app allows users to transact using an HTML frontend on a browser, and the transactions are recorded on the Postgres database.
There are several ways to install and run the app:
-
Clone the repository:
git clone https://github.com/cldcvr/codepipes-tutorials.git
-
Navigate to the root directory of the app:
cd apps/04-golang-pgsql
-
Start the app using Go CLI:
go run main.go
-
Open a browser and go to
http://localhost:3000
to use the app.
-
Clone the repository:
git clone https://github.com/cldcvr/codepipes-tutorials.git
-
Navigate to the root directory of the app:
cd apps/04-golang-pgsql
-
Build the Docker image using the Dockerfile:
docker build -t demo-go-app .
-
Start the app using Docker:
docker run -p 8080:8080 demo-go-app
-
Open a browser and go to
http://localhost:3000
to use the app.
-
Clone the repository:
git clone https://github.com/cldcvr/codepipes-tutorials.git
-
Navigate to the root directory of the app:
cd apps/04-golang-pgsql
-
Start the app and its dependencies using Docker Compose:
docker-compose up -d
-
Open a browser and go to
http://localhost:3000
to use the app.
-
Clone the repository:
git clone https://github.com/cldcvr/codepipes-tutorials.git
-
Navigate to the root directory of the app:
cd apps/04-golang-pgsql
-
Build the app using make command:
make build
-
Start the app using make command:
make run
-
Open a browser and go to
http://localhost:3000
to use the app.
In order to connect to the Postgres server, the app needs the following environment variables:
DB_PASSWORD
: The password for the Postgres databaseDB_HOST
: The host where the Postgres database is running. By default, it is set todb
.DB_USER
: The username for the Postgres database. By default, it is set topostgres
.DB_NAME
: The name of the Postgres database. By default, it is set topostgres
.DB_PORT
: The port number of the Postgres database. By default, it is set to5432
.DB_SSLMODE
: The SSL mode for the Postgres database. By default, it is set todisable
.
Make sure to set these environment variables before running the app. You can set them using a .env
file or by exporting them in the terminal.
This app is licensed under the MIT License. See the LICENSE file for details.