2024-09-06 01:02:25 -04:00
|
|
|
# Stage 1: Build the application
|
2024-09-06 19:29:09 -04:00
|
|
|
FROM golang:1.22-alpine AS builder
|
2024-06-30 21:41:41 -04:00
|
|
|
|
|
|
|
WORKDIR /usr/src/app
|
|
|
|
|
|
|
|
COPY go.mod go.sum ./
|
|
|
|
RUN go mod download && go mod verify
|
|
|
|
|
2024-09-05 23:01:53 -04:00
|
|
|
COPY . .
|
2024-09-06 01:02:25 -04:00
|
|
|
RUN CGO_ENABLED=1 GOOS=linux go build -ldflags="-s -w" -buildvcs=false -o /donetick
|
|
|
|
|
|
|
|
# Stage 2: Create a smaller runtime image
|
|
|
|
FROM alpine:latest
|
|
|
|
|
|
|
|
# Install necessary CA certificates
|
2024-09-06 19:29:09 -04:00
|
|
|
RUN apk --no-cache add ca-certificates libc6-compat
|
2024-09-06 01:02:25 -04:00
|
|
|
|
|
|
|
# Copy the binary and config folder from the builder stage
|
|
|
|
COPY --from=builder /donetick /donetick
|
|
|
|
COPY --from=builder /usr/src/app/config /config
|
|
|
|
|
|
|
|
# Set environment variables
|
2024-09-05 22:42:25 -04:00
|
|
|
ENV DT_ENV="selfhosted"
|
2024-09-06 01:02:25 -04:00
|
|
|
|
|
|
|
# Expose the application port
|
|
|
|
EXPOSE 2021
|
|
|
|
|
|
|
|
# Command to run the application
|
2024-09-05 22:58:22 -04:00
|
|
|
CMD ["/donetick"]
|