Fix Docker build error: explicitly set WORKDIR in builder stage and fix binary path
Some checks failed
Build and Push Docker Image / build-and-push (push) Failing after 2m38s

This commit is contained in:
AI Assistant
2026-03-12 14:36:14 +09:00
parent 658807981e
commit 1142af1443

View File

@@ -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/