Basic cleaning
This commit is contained in:
parent
d3f66febaf
commit
6b7faf1899
10
Makefile
Normal file
10
Makefile
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
export NAME=genityapp
|
||||||
|
|
||||||
|
build:
|
||||||
|
docker-compose build
|
||||||
|
|
||||||
|
run: build
|
||||||
|
docker-compose up
|
||||||
|
|
||||||
|
build-binary:
|
||||||
|
GOOS=linux GOARCH=amd64 go build
|
|
@ -22,11 +22,11 @@ func main() {
|
||||||
initDb()
|
initDb()
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
http.HandleFunc("/api/users", UserGetHandler)
|
http.HandleFunc("/get-data", UserGetHandler)
|
||||||
http.HandleFunc("/api/user", UserPostHandler)
|
http.HandleFunc("/post-data", UserPostHandler)
|
||||||
|
|
||||||
fmt.Println("Listening on :8080")
|
fmt.Println("Listening on :5000")
|
||||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
log.Fatal(http.ListenAndServe(":5000", nil))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,16 +48,11 @@ func initDb() {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
fmt.Println("Successfully connected!")
|
fmt.Println("Successfully connected!")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func dbConfig() map[string]string {
|
func dbConfig() map[string]string {
|
||||||
conf := make(map[string]string)
|
conf := make(map[string]string)
|
||||||
conf[dbhost] = "poc-golang-postgres-docker_db_1"
|
conf[dbhost] = "genitywebapp_db_1"
|
||||||
conf[dbport] = "5432"
|
conf[dbport] = "5432"
|
||||||
conf[dbuser] = "root_user"
|
conf[dbuser] = "root_user"
|
||||||
conf[dbpass] = "shahzad12"
|
conf[dbpass] = "shahzad12"
|
3
db.env
Normal file
3
db.env
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
POSTGRES_DB=db_genity
|
||||||
|
POSTGRES_USER=root_user
|
||||||
|
POSTGRES_PASSWORD=shahzad12
|
4
db_dump
4
db_dump
|
@ -1,4 +0,0 @@
|
||||||
CREATE TABLE users ( user_id serial PRIMARY KEY, title VARCHAR ( 50 ) UNIQUE NOT NULL, created_on TIMESTAMP NOT NULL);
|
|
||||||
INSERT INTO users (title,created_on) VALUES('shahzad','2013-06-01');
|
|
||||||
|
|
||||||
|
|
1
ddl_01.sql
Normal file
1
ddl_01.sql
Normal file
|
@ -0,0 +1 @@
|
||||||
|
CREATE TABLE users (user_id serial PRIMARY KEY, title VARCHAR ( 50 ) UNIQUE NOT NULL, created_on TIMESTAMP NOT NULL);
|
1
dml_01.sql
Normal file
1
dml_01.sql
Normal file
|
@ -0,0 +1 @@
|
||||||
|
INSERT INTO users (title,created_on) VALUES('shahzad','2013-06-01');
|
|
@ -2,21 +2,25 @@ version: '3'
|
||||||
services:
|
services:
|
||||||
db:
|
db:
|
||||||
image: postgres
|
image: postgres
|
||||||
environment:
|
env_file:
|
||||||
POSTGRES_DB: db_genity
|
- ./db.env
|
||||||
POSTGRES_USER: root_user
|
|
||||||
POSTGRES_PASSWORD: shahzad12
|
|
||||||
volumes:
|
volumes:
|
||||||
- db_postgres:/var/lib/postgresql/data
|
- ./db_postgres:/var/lib/postgresql/data
|
||||||
ports:
|
- ./ddl_01.sql:/docker-entrypoint-initdb.d/10_schema.sql
|
||||||
- "5436:5432"
|
- ./dml_01.sql:/docker-entrypoint-initdb.d/20_insert.sql
|
||||||
|
expose:
|
||||||
|
- "5432"
|
||||||
|
restart: always
|
||||||
networks:
|
networks:
|
||||||
- genity_network
|
- genity_network
|
||||||
app:
|
web:
|
||||||
build: ""
|
build: ""
|
||||||
command: [ "go", "run", "main.go","api.go"]
|
command: [ "go", "run", "main.go","api.go"]
|
||||||
|
env_file:
|
||||||
|
- ./web.env
|
||||||
ports:
|
ports:
|
||||||
- "8080:8080"
|
- "5000:5000"
|
||||||
|
restart: always
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
links:
|
links:
|
||||||
|
|
Loading…
Reference in a new issue