diff --git a/Dockerfile b/Dockerfile index 8e4a4f1..85bce1a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,12 @@ # 1. Build Go Backend FROM golang:1.21-alpine AS builder -WORKDIR /app -# TODO: go mod init & go mod download will be added later when we create the go backend code -# COPY backend/go.mod backend/go.sum ./backend/ -# RUN cd backend && go mod download +# Cache go modules +COPY backend/go.mod backend/go.sum ./backend/ +RUN cd backend && go mod download + COPY backend/ ./backend/ -# We'll build the go binary inside the backend dir and put it in /app/main -RUN cd backend && CGO_ENABLED=1 go build -o /app/main main.go +# We'll build the go binary inside the backend dir and put it in /app/main. Remove debug info for smaller binary. +RUN cd backend && CGO_ENABLED=1 go build -ldflags="-s -w" -o /app/main main.go # 2. Final Minimal Image (Python + Go binary + Frontend) FROM python:3.10-slim diff --git a/backend/models/db.go b/backend/models/db.go index d347c0e..5953080 100644 --- a/backend/models/db.go +++ b/backend/models/db.go @@ -39,6 +39,9 @@ func InitDB(dbPath string) { log.Fatal("Failed to connect to database:", err) } + // SQLite 동시성 최적화를 위해 WAL(Write-Ahead Logging) 모드를 활성화 + DB.Exec("PRAGMA journal_mode=WAL;") + err = DB.AutoMigrate(&MediaHistory{}) if err != nil { log.Println("Database migration error:", err) diff --git a/worker/requirements.txt b/worker/requirements.txt index 2920b7b..b1df116 100644 --- a/worker/requirements.txt +++ b/worker/requirements.txt @@ -1,2 +1 @@ yt-dlp -ffmpeg-python