Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "log"
- "github.com/jinzhu/gorm"
- _ "github.com/jinzhu/gorm/dialects/postgres"
- )
- type Product struct {
- gorm.Model
- Code string
- Price uint
- }
- var db *gorm.DB
- func init() {
- connection := fmt.Sprintf("host=db sslmode=disable user=dnz-dev password=dnz-dev")
- db, err := gorm.Open("postgres", connection)
- if err != nil {
- log.Fatalln(err)
- }
- defer db.Close()
- }
- func main() {
- // Migrate the schema
- db.AutoMigrate(&Product{})
- }
- services:
- db:
- build: ./dnz-db
- container_name: dnz-database
- ports:
- - "6000:5432"
- volumes:
- - ./dnz-db/data:/var/lib/postgresql/data
- environment:
- - POSTGRES_USER=dnz-dev
- - POSTGRES_PASSWORD=dnz-dev
- api:
- build: ./dnz-api
- container_name: dnz-api
- volumes:
- - ./dnz-api:/go/src/app
- ports:
- - "5000:3000"
- depends_on:
- - db
Add Comment
Please, Sign In to add comment