A minimalistic example of a web app accessing a PostgreSQL [1]database written in Go [2].
The app is intended for demonstration purposes as part of Containerization tutorials.
Assuming there is a PostgreSQL server running with a user postgres
and an empty database postgresl
:
POSTGRES_HOST=<postgresql-host> POSTGRES_USERNAME=<postgresql-username> POSTGRES_PASSWORD=<postgresl-password> go run main.go
docker image build -t smpl-go-pg:0.2.0 .
docker image tag smpl-go-pg:0.2.0 fischerjulian/smpl-go-pg:0.2.0
docker image push fischerjulian/smpl-go-pg:0.2.0
docker image pull fischerjulian/smpl-go-pg:0.2.0
In order to run the image you will also have to set the env vars POSTGRES_HOST
and POSTGRES_PASSWORD
which is not contained in the examples below as the images will be used in the context of Kubernetes, only.
Run local image with version tag 0.2.0
:
docker container run -p 8080:8080 smpl-go-pg:0.2.0
Run remote image with version tag 0.2.0
:
docker container run -p 8080:8080 fischerjulian/smpl-go-pg:0.2.0
- PostgreSQL, https://www.postgresql.org/
- Go, https://golang.org/
- Go PQ, https://github.com/lib/pq