Add cron job functionality and Docker integration

This commit is contained in:
2026-01-31 00:31:43 +03:00
parent 73acc5410f
commit 3132ab2fa2
6 changed files with 210 additions and 30 deletions

View File

@@ -12,16 +12,22 @@ RUN go mod download
# Copy source code
COPY . .
# Build the binary
# Build the main binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags="-s -w" \
-o /app/quoteforge \
./cmd/server
# Build the cron binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags="-s -w" \
-o /app/quoteforge-cron \
./cmd/cron
# Final stage
FROM alpine:3.19
RUN apk add --no-cache ca-certificates tzdata
RUN apk add --no-cache ca-certificates tzdata cron
# Create non-root user
RUN adduser -D -g '' appuser
@@ -30,6 +36,14 @@ WORKDIR /app
# Copy binary from builder
COPY --from=builder /app/quoteforge .
COPY --from=builder /app/quoteforge-cron .
# Copy cron job configuration
COPY crontab /etc/crontabs/appuser
RUN chmod 0600 /etc/crontabs/appuser
# Create log directory
RUN mkdir -p /var/log/cron
# Copy web templates and static files
COPY --from=builder /app/web ./web