Skip to content

Commit

Permalink
feat: add .gitignore entries for Docker data directories and update M…
Browse files Browse the repository at this point in the history
…akefile and docker-compose.prod.yaml
  • Loading branch information
peterxcli committed Feb 18, 2024
1 parent 3999871 commit a8cbe62
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 5 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@ logs/
*.out

# Temp files (hot reload)
tmp_app/
tmp_app/

docker/db-data/
docker/redis-data/
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,7 @@ docs: install ## Generate the swagger docs
swag init --parseDependency --parseInternal -g ./cmd/backend/main.go

bot: ## Run the bot
./script/run.sh dev bot
./script/run.sh dev bot

prod-up: ## Start the container for production
./script/run.sh prod start
9 changes: 7 additions & 2 deletions cmd/backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ package main
import (
"bikefest/docs"
"bikefest/pkg/bootstrap"
"bikefest/pkg/model"
"bikefest/pkg/router"
"bikefest/pkg/service"
"fmt"
"github.com/hibiken/asynq"
"github.com/hibiken/asynqmon"
"net/http"
"net/http/httputil"

"github.com/hibiken/asynq"
"github.com/hibiken/asynqmon"

"github.com/gin-gonic/gin"
swaggerfiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger"
Expand Down Expand Up @@ -79,6 +81,9 @@ func main() {
AsynqService: asynqService,
}

// Migration
app.Conn.AutoMigrate(&model.User{}, &model.Event{}, &model.PsychoTest{})

// Init routes
router.RegisterRoutes(app, services)

Expand Down
58 changes: 58 additions & 0 deletions docker/docker-compose.prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
version: "3.7"

services:
backend:
image: ghcr.io/gdsc-ncku/bike-festival-2024-backend-backend:v1.0.0
restart: always
pull_policy: always
env_file:
- ../.env.prod

ports:
- 8000:8000
networks:
- bike-networks
depends_on:
- db
- redis

notifier:
image: ghcr.io/gdsc-ncku/bike-festival-2024-backend-notifier:v1.0.0
restart: always
pull_policy: always
env_file:
- ../.env.prod
networks:
- bike-networks
depends_on:
- db
- redis
db:
image: postgres:latest
restart: always
environment:
POSTGRES_DATABASE: ${APP_DB_DATABASE}
POSTGRES_USER: ${APP_DB_USERNAME}
POSTGRES_PASSWORD: ${APP_DB_PASSWORD}
# ports:
# - "5432:5432"
networks:
- bike-networks
volumes:
- ./db-data:/var/lib/postgresql/data

redis:
image: redis:latest
restart: always
environment:
TZ: ${APP_SERVER_TIMEZONE}
ports:
- ${APP_REDIS_PORT}:6379
networks:
- bike-networks
volumes:
- ./redis-data:/data

networks:
bike-networks:
driver: bridge
2 changes: 1 addition & 1 deletion script/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ case "$mode" in
exit 0
;;

dev|stage|test)
dev|stage|test|prod)
# All actions for these modes are handled in the next switch case block
;;

Expand Down

0 comments on commit a8cbe62

Please sign in to comment.