Skip to content

Commit a6d3d87

Browse files
authored
Merge pull request #4 from jarifibrahim/master
Use centos/postgresql as database image and clean up application.yaml
2 parents 22b9ec8 + 6dd1369 commit a6d3d87

File tree

4 files changed

+23
-30
lines changed

4 files changed

+23
-30
lines changed

.openshiftio/application.yaml

-26
Original file line numberDiff line numberDiff line change
@@ -97,21 +97,6 @@ objects:
9797
spec:
9898
containers:
9999
- env:
100-
- name: DB_USERNAME
101-
valueFrom:
102-
secretKeyRef:
103-
name: my-database-secret
104-
key: user
105-
- name: DB_PASSWORD
106-
valueFrom:
107-
secretKeyRef:
108-
name: my-database-secret
109-
key: password
110-
- name: DB_HOST
111-
valueFron:
112-
secretKeyRef:
113-
name: my-database-secret
114-
key: host
115100
readinessProbe:
116101
httpGet:
117102
path: /api/fruits
@@ -172,14 +157,3 @@ objects:
172157
labels:
173158
project: golang-http-crud
174159
version: '${RELEASE_VERSION}'
175-
- apiVersion: v1
176-
kind: Secret
177-
metadata:
178-
name: my-database-secret
179-
labels:
180-
app: golang-http-crud
181-
version: '${RELEASE_VERSION}'
182-
stringData:
183-
user: postgres
184-
password: mysecretpassword
185-
host: my-database

.openshiftio/service.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ items:
1313
spec:
1414
tags:
1515
- annotations:
16-
openshift.io/imported-from: postgresql/postgresql:9.6
16+
openshift.io/imported-from: centos/postgresql-96-centos7
1717
from:
1818
kind: DockerImage
19-
name: postgresql/postgresql:9.6
19+
name: centos/postgresql-96-centos7
2020
generation: null
2121
importPolicy: {}
2222
name: latest
@@ -53,7 +53,7 @@ items:
5353
- env:
5454
- name: POSTGRESQL_ADMIN_PASSWORD
5555
value: mysecretpassword
56-
image: postgresql/postgresql:9.6
56+
image: centos/postgresql-96-centos7
5757
name: my-database
5858
ports:
5959
- containerPort: 5432

README.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Golang CRUD Booster
2+
3+
#### Running Locally
4+
5+
First, install the dependencies
6+
`go get`
7+
8+
The web app requires Postgres DB. If you have docker installed, you can run the
9+
following command to start a new Postgres container
10+
11+
`docker run -e POSTGRESQL_ADMIN_PASSWORD=mysecretpassword -d -p 5432:5432 centos/postgresql-96-centos7`
12+
13+
In this example, the database user is `postgres`, the password is `mysecretpassword` and the database is `postgres`
14+
15+
You can then start the application like this:
16+
17+
`go build && ./golang-http-crud`
18+
19+
Then go to http://localhost:8080

main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
)
1414

1515
func main() {
16-
pgHost := getEnv("DB_HOST", "localhost")
16+
pgHost := getEnv("MY_DATABASE_SERVICE_HOST", "localhost")
1717
pgPort := getEnv("DB_PORT", "5432")
1818
pgUser := getEnv("DB_USERNAME", "postgres")
1919
pgDBname := getEnv("DB_DBNAME", "postgres")

0 commit comments

Comments
 (0)