PostgreSQL is used as the peristence layer, in order to run the application on your machine ensure you have PostgreSQL installed and running.
The application requires a .env
with the following variables.
API_PORT=8080
DB_HOST=
DB_PORT=
DB_USER=
DB_NAME=
DB_PASSWORD=
podman build \
--build-arg=CGO_ENABLED=0 \
--build-arg=GOOS=linux \
--build-arg=GOARCH=amd64 \
-t go-todo:<version /> .
podman run --name=go-todo --env-file=.env -p 8080:8080 localhost/go-todo:<version />
podman run --name=go-todo \
--pod=go-todo-pod \
-e API_PORT=8080 \
-e DB_HOST=localhost \
-e DB_PORT=5432 \
-e DB_USER=username \
-e DB_PASSWORD=password \
-e DB_NAME=tasks \
-p 8080:8080 localhost/go-todo:<version />
oc new-app --name todo-api --image=quay.io/cbennett/go-todo:v1.0.3 \
-e API_PORT=8080 \
-e DB_HOST= \
-e DB_PORT=5432 \
-e DB_USER=user \
-e DB_PASSWORD=password \
-e DB_NAME=tasks
oc new-app \
--name todo-db-postgresql \
--image=registry.redhat.io/rhel8/postgresql-12:1-177 \
-e POSTGRESQL_USER=user \
-e POSTGRESQL_DATABASE=db \
-e POSTGRESQL_PASSWORD=password
podman run \
--pod=go-todo-pod \
--name postgresdb \
-e POSTGRES_USER=username \
-e POSTGRES_PASSWORD=password \
-p 5432:5432 \
-v ~/dev/postgres/data \
-d postgres
podman run --pod=go-todo-pod \
--name=go-todo \
--env-file=.env localhost/go-todo:v1.0.0
podman run --pod=go-todo-pod \
--name postgresdb \
-e POSTGRES_USER=username \
-e POSTGRES_PASSWORD=password \
-v ~/dev/postgres/data \
-d postgres
podman run --pod=go-todo-pod \
-e 'PGADMIN_DEFAULT_EMAIL=user@example.com' \
-e 'PGADMIN_DEFAULT_PASSWORD=topsecret' \
--name pgadmin \
-d docker.io/dpage/pgadmin4
curl http://localhost:8080/todos | jq
curl http://localhost:8080/todos/{id} | jq
curl --header "Content-Type: application/json" \
--request POST \
--data '{"task":"My todo task","author":"Colum B"}' \
http://localhost:3000/todos
curl -X PUT \
--data '{"task":"My todo task that is updated","author":"Colum B"}' \
http://localhost:8080/todos/{id} | jq
curl -X DELETE http://localhost:8080/todos/{id}