diff --git a/Dockerfile b/Dockerfile index a56850b..c121907 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,13 +4,15 @@ FROM golang:1.22-alpine AS builder # SQLite 및 CGO 빌드에 필요한 패키지 설치 RUN apk add --no-cache gcc musl-dev -# Cache go modules -COPY backend/go.mod backend/go.sum ./backend/ -RUN cd backend && go mod download +WORKDIR /build -COPY backend/ ./backend/ -# 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 +# Cache go modules +COPY backend/go.mod backend/go.sum ./ +RUN go mod download + +COPY backend/ ./ +# CGO_ENABLED=1 is required for sqlite3 +RUN CGO_ENABLED=1 go build -ldflags="-s -w" -o main main.go # 2. Final Minimal Image (Python + Go binary + Frontend) FROM python:3.10-slim @@ -31,7 +33,7 @@ COPY worker/requirements.txt ./worker/ RUN pip install --no-cache-dir -r worker/requirements.txt # Copy Go binary from builder -COPY --from=builder /app/main ./main +COPY --from=builder /build/main ./main # Copy worker script COPY worker/ ./worker/