Add cron job functionality and Docker integration
This commit is contained in:
18
Dockerfile
18
Dockerfile
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user