diff --git a/.env.template b/.env.template index 6849af4..cd14ee6 100644 --- a/.env.template +++ b/.env.template @@ -12,7 +12,7 @@ JWT_RESET_TOKEN_TTL=900 REDIS_HOST=localhost REDIS_PORT=6379 -REDIS_PASSWORD= +REDIS_PASSWORD=5678 AUTH_CLIENT_URL=http://localhost:3000 diff --git a/Makefile b/Makefile index 0f0088b..a05077d 100644 --- a/Makefile +++ b/Makefile @@ -15,8 +15,8 @@ test: server: go run ./cmd/. -docker-qa: - docker-compose -f docker-compose.qa.yaml up +docker: + docker-compose up mock-gen: mockgen -source ./internal/cache/cache.repository.go -destination ./mocks/repository/cache/cache.mock.go diff --git a/README.md b/README.md index ad46256..627dc6e 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Johnjud is a pet adoption web application of the [CUVET For Animal Welfare Club] 3. Run `go mod download` to download all the dependencies. ### Running -1. Run `docker-compose -f docker-compose.example.yaml up` +1. Run `docker-compose up` 2. Run `make server` or `go run ./cmd/.` ### Testing diff --git a/database/postgresql.connection.go b/database/postgresql.connection.go index 5c87268..f6069f8 100644 --- a/database/postgresql.connection.go +++ b/database/postgresql.connection.go @@ -20,7 +20,7 @@ func InitPostgresDatabase(conf *config.Database, isDebug bool) (db *gorm.DB, err return nil, err } - err = db.AutoMigrate(&model.User{}, &model.AuthSession{}) + err = db.AutoMigrate(&model.User{}, &model.AuthSession{}, &model.Pet{}, &model.Image{}) if err != nil { return nil, err } diff --git a/docker-compose-prod.yaml b/docker-compose-prod.yaml deleted file mode 100644 index 9d7d772..0000000 --- a/docker-compose-prod.yaml +++ /dev/null @@ -1,120 +0,0 @@ -version: "3.9" - -services: - gateway: - container_name: johnjud-gateway - restart: unless-stopped - build: . - ports: - - 3001:3001 - environment: - - APP_PORT=3001 - - APP_ENV=development - - APP_MAX_FILE_SIZE=10 - - SERVICE_AUTH=auth:3002 - - SERVICE_BACKEND=backend:3003 - - SERVICE_FILE=file:3004 - networks: - - johnjud-local - local-auth: - image: ghcr.io/isd-sgcu/johnjud-auth - container_name: auth - depends_on: - - local-db - - local-cache - restart: unless-stopped - environment: - - APP_PORT=3002 - - APP_ENV=production - - APP_SECRET=secret - - DB_URL=postgres://root:root@local-db:5432/johnjud_db - - JWT_SECRET=secret - - JWT_EXPIRES_IN=3600 - - JWT_REFRESH_TOKEN_TTL=604800 - - JWT_ISSUER=issuer - - JWT_RESET_TOKEN_TTL=900 - - REDIS_HOST=local-cache - - REDIS_PORT=6379 - - REDIS_PASSWORD= - - AUTH_CLIENT_URL=http://localhost:3000 - - SENDGRID_API_KEY=api_key - - SENDGRID_NAME=johnjud - - SENDGRID_ADDRESS=johnjud@gmail.com - networks: - - johnjud-local - - database - ports: - - "3002:3002" - - local-backend: - image: ghcr.io/isd-sgcu/johnjud-backend - container_name: backend - depends_on: - - local-db - - local-cache - restart: unless-stopped - environment: - - APP_PORT=3003 - - APP_ENV=production - - DB_URL=postgres://root:root@local-db:5432/johnjud_db - - SERVICE_FILE=file:3004 - networks: - - johnjud-local - - database - ports: - - "3003:3003" - - local-file: - image: ghcr.io/isd-sgcu/johnjud-file - container_name: file - depends_on: - - local-db - - local-cache - restart: unless-stopped - environment: - - APP_PORT=3004 - - APP_ENV=production - - DB_URL=postgres://root:root@local-db:5432/johnjud_db - - BUCKET_ENDPOINT=minio-api.isd.sgcu.in.th - - BUCKET_ACCESS_KEY=BUCKET_ACCESS_KEY - - BUCKET_SECRET_KEY=BUCKET_SECRET_KEY - - BUCKET_NAME=johnjud-pet-images - - BUCKET_USE_SSL=true - networks: - - johnjud-local - - database - ports: - - "3004:3004" - - local-db: - image: postgres:15.1-alpine3.17 - container_name: local-db - restart: unless-stopped - environment: - POSTGRES_USER: root - POSTGRES_PASSWORD: root - POSTGRES_DB: johnjud_db - networks: - - database - volumes: - - ./volumes/postgres:/var/lib/postgresql/data - ports: - - "5432:5432" - - local-cache: - image: redis:7.2.3-alpine - container_name: local-cache - restart: unless-stopped - environment: - REDIS_HOST: localhost - ALLOW_EMPTY_PASSWORD: "yes" - networks: - - database - ports: - - "6379:6379" - -networks: - johnjud-local: - name: johnjud-local - database: - name: database diff --git a/docker-compose.example.yaml b/docker-compose.example.yaml deleted file mode 100644 index 54d0f68..0000000 --- a/docker-compose.example.yaml +++ /dev/null @@ -1,105 +0,0 @@ -version: "3.9" - -services: - local-auth: - image: ghcr.io/isd-sgcu/johnjud-auth - container_name: auth - depends_on: - - local-db - - local-cache - restart: unless-stopped - environment: - - APP_PORT=3002 - - APP_ENV=development - - APP_SECRET=secret - - DB_URL=postgres://root:root@local-db:5432/johnjud_db - - JWT_SECRET=secret - - JWT_EXPIRES_IN=3600 - - JWT_REFRESH_TOKEN_TTL=604800 - - JWT_ISSUER=issuer - - JWT_RESET_TOKEN_TTL=900 - - REDIS_HOST=local-cache - - REDIS_PORT=6379 - - REDIS_PASSWORD= - - AUTH_CLIENT_URL=http://localhost:3000 - - SENDGRID_API_KEY=api_key - - SENDGRID_NAME=johnjud - - SENDGRID_ADDRESS=johnjud@gmail.com - networks: - - johnjud-local - - database - ports: - - "3002:3002" - - local-backend: - image: ghcr.io/isd-sgcu/johnjud-backend - container_name: backend - depends_on: - - local-db - - local-cache - restart: unless-stopped - environment: - - APP_PORT=3003 - - APP_ENV=development - - DB_URL=postgres://root:root@local-db:5432/johnjud_db - - SERVICE_FILE=file:3004 - networks: - - johnjud-local - - database - ports: - - "3003:3003" - - local-file: - image: ghcr.io/isd-sgcu/johnjud-file - container_name: file - depends_on: - - local-db - - local-cache - restart: unless-stopped - environment: - - APP_PORT=3004 - - APP_ENV=production - - DB_URL=postgres://root:root@local-db:5432/johnjud_db - - BUCKET_ENDPOINT=minio-api.isd.sgcu.in.th - - BUCKET_ACCESS_KEY=BUCKET_ACCESS_KEY - - BUCKET_SECRET_KEY=BUCKET_SECRET_KEY - - BUCKET_NAME=johnjud-pet-images - - BUCKET_USE_SSL=true - networks: - - johnjud-local - - database - ports: - - "3004:3004" - - local-db: - image: postgres:15.1-alpine3.17 - container_name: local-db - restart: unless-stopped - environment: - POSTGRES_USER: root - POSTGRES_PASSWORD: root - POSTGRES_DB: johnjud_db - networks: - - database - volumes: - - ./volumes/postgres:/var/lib/postgresql/data - ports: - - "5432:5432" - - local-cache: - image: redis:7.2.3-alpine - container_name: local-cache - restart: unless-stopped - environment: - REDIS_HOST: localhost - ALLOW_EMPTY_PASSWORD: "yes" - networks: - - database - ports: - - "6379:6379" - -networks: - johnjud-local: - name: johnjud-local - database: - name: database diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..b9d27da --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,36 @@ +version: "3.9" + +services: + local-db: + image: postgres:15.1-alpine3.17 + container_name: local-db + restart: unless-stopped + environment: + POSTGRES_USER: root + POSTGRES_PASSWORD: root + POSTGRES_DB: johnjud_db + networks: + - database + volumes: + - postgres:/var/lib/postgresql/data + ports: + - "5432:5432" + + local-cache: + image: redis:7.2.3-alpine + container_name: local-cache + restart: unless-stopped + environment: + REDIS_HOST: localhost + REDIS_PASSWORD: 5678 + networks: + - database + ports: + - "6379:6379" + +networks: + database: + name: database + +volumes: + postgres: \ No newline at end of file