Skip to content

Commit

Permalink
Merge pull request #21 from isd-sgcu/dev
Browse files Browse the repository at this point in the history
Update main
  • Loading branch information
bookpanda authored Jan 16, 2024
2 parents 19b794a + e6ec640 commit efb3427
Show file tree
Hide file tree
Showing 23 changed files with 478 additions and 270 deletions.
6 changes: 6 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
APP_PORT=3003
APP_ENV=development

DB_URL=postgres://root:root@localhost:5432/johnjud_db

SERVICE_FILE=localhost:3004
13 changes: 13 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Change made

- [ ]  New features
- [ ]  Bug fixes
- [ ]  Breaking changes
## Describe what you have done
-
### New Features
-
### Fix
-
### Others
-
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Set branch
id: branch
run: |
echo "::set-output name=BRANCH::${GITHUB_REF#refs/heads/}"
echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
- name: Log in to the Container Registry
uses: docker/login-action@v1
Expand All @@ -48,6 +48,7 @@ jobs:
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }},${{ env.IMAGE_NAME }}:latest
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
config.yaml
.env
.env.prod
.env.file

# idea
.idea
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ test:
go tool cover -html=coverage.out -o coverage.html

server:
go run ./src/.
. ./tools/export-env.sh ; go run ./src/.
13 changes: 0 additions & 13 deletions config/config.example.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions config/file/config.example.yaml

This file was deleted.

55 changes: 55 additions & 0 deletions docker-compose-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
version: "3.9"

services:
backend:
container_name: johnjud-backend
restart: unless-stopped
build: .
ports:
- 3003:3003
environment:
- APP_PORT=3003
- APP_ENV=production
- DB_URL=postgres://root:root@johnjud-local-db:5432/johnjud_db
- SERVICE_FILE=localhost:3004
networks:
- johnjud
local-file:
image: ghcr.io/isd-sgcu/johnjud-file
container_name: johnjud-file
depends_on:
- local-db
restart: unless-stopped
environment:
- APP_PORT=3004
- APP_ENV=production
- DB_URL=postgres://root:root@johnjud-local-db:5432/johnjud_db
- BUCKET_ENDPOINT=BUCKET_ENDPOINT
- BUCKET_ACCESS_KEY=BUCKET_ACCESS_KEY
- BUCKET_SECRET_KEY=BUCKET_SECRET_KEY
- BUCKET_NAME=johnjud-pet-images
- BUCKET_USE_SSL=false
ports:
- "3004:3004"
networks:
- johnjud

local-db:
image: postgres:15.1-alpine3.17
container_name: johnjud-local-db
restart: unless-stopped
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: root
POSTGRES_DB: johnjud_db
volumes:
- postgres:/var/lib/postgresql/data
ports:
- "5432:5432"
networks:
- johnjud

volumes:
postgres:
networks:
johnjud:
21 changes: 17 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,23 @@ version: "3.9"
services:
local-file:
image: ghcr.io/isd-sgcu/johnjud-file
container_name: file
container_name: johnjud-file
depends_on:
- local-db
restart: unless-stopped
volumes:
- ./config/file:/app/config
environment:
- APP_PORT=3004
- APP_ENV=development
- DB_URL=postgres://root:root@johnjud-local-db:5432/johnjud_db
- BUCKET_ENDPOINT=BUCKET_ENDPOINT
- BUCKET_ACCESS_KEY=BUCKET_ACCESS_KEY
- BUCKET_SECRET_KEY=BUCKET_SECRET_KEY
- BUCKET_NAME=johnjud-pet-images
- BUCKET_USE_SSL=false
ports:
- "3004:3004"
networks:
- johnjud

local-db:
image: postgres:15.1-alpine3.17
Expand All @@ -24,6 +33,10 @@ services:
- postgres:/var/lib/postgresql/data
ports:
- "5432:5432"
networks:
- johnjud

volumes:
postgres:
postgres:
networks:
johnjud:
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ toolchain go1.21.5
require (
github.com/bxcodec/faker/v3 v3.8.1
github.com/google/uuid v1.5.0
github.com/isd-sgcu/johnjud-go-proto v0.0.9
github.com/pkg/errors v0.9.1
github.com/isd-sgcu/johnjud-go-proto v0.5.0
github.com/rs/zerolog v1.31.0
github.com/spf13/viper v1.18.2
github.com/spf13/viper v1.18.1
github.com/stretchr/testify v1.8.4
google.golang.org/grpc v1.60.1
gorm.io/driver/postgres v1.5.4
Expand Down
9 changes: 4 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=
github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/isd-sgcu/johnjud-go-proto v0.0.9 h1:cFfZ2JSpW0jg94Iv5zHQJGnoekj0eCQe42SJaTpnp3c=
github.com/isd-sgcu/johnjud-go-proto v0.0.9/go.mod h1:1OK6aiCgtXQiLhxp0r6iLEejYIRpckWQZDrCZ9Trbo4=
github.com/isd-sgcu/johnjud-go-proto v0.5.0 h1:GgqRzWjya5p1yhfU/kpX8i4WL42+qT2TkyXZmssH6B4=
github.com/isd-sgcu/johnjud-go-proto v0.5.0/go.mod h1:1OK6aiCgtXQiLhxp0r6iLEejYIRpckWQZDrCZ9Trbo4=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
Expand All @@ -47,7 +47,6 @@ github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyua
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4=
github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
Expand All @@ -69,8 +68,8 @@ github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ=
github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk=
github.com/spf13/viper v1.18.1 h1:rmuU42rScKWlhhJDyXZRKJQHXFX02chSVW1IvkPGiVM=
github.com/spf13/viper v1.18.1/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
Expand Down
6 changes: 3 additions & 3 deletions src/app/model/pet/pet.model.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import (
type Pet struct {
model.Base
Type string `json:"type" gorm:"tinytext"`
Species string `json:"species" gorm:"tinytext"`
Name string `json:"name" gorm:"tinytext"`
Birthdate string `json:"birthdate" gorm:"tinytext"`
Gender pet.Gender `json:"gender" gorm:"tinytext" example:"male"`
Color string `json:"color" gorm:"tinytext"`
Pattern string `json:"pattern" gorm:"tinytext"`
Habit string `json:"habit" gorm:"mediumtext"`
Caption string `json:"caption" gorm:"mediumtext"`
Status pet.Status `json:"status" gorm:"mediumtext" example:"findhome"`
IsSterile bool `json:"is_sterile"`
IsVaccinated bool `json:"is_vaccine"`
IsVisible bool `json:"is_visible"`
IsClubPet bool `json:"is_club_pet"`
Background string `json:"background" gorm:"tinytext"`
Origin string `json:"origin" gorm:"tinytext"`
Address string `json:"address" gorm:"tinytext"`
Contact string `json:"contact" gorm:"tinytext"`
AdoptBy string `json:"adopt_by" gorm:"tinytext"`
Expand Down
2 changes: 1 addition & 1 deletion src/app/repository/pet/pet.repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (r *Repository) FindAll(result *[]*pet.Pet) error {
}

func (r *Repository) FindOne(id string, result *pet.Pet) error {
return r.db.Model(&pet.Pet{}).Find(result, "id = ?", id).Error
return r.db.Model(&pet.Pet{}).First(result, "id = ?", id).Error
}

func (r *Repository) Create(in *pet.Pet) error {
Expand Down
Loading

0 comments on commit efb3427

Please sign in to comment.