forked from fly-apps/cron-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
42 lines (33 loc) · 1.32 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Start from Ubuntu 20.04 as the base for the build stage to ensure compatibility
FROM golang:1.21.0 as builder
WORKDIR /app
# Copy your source code
COPY . .
# Build your Go application
RUN CGO_ENABLED=1 GOOS=linux go build -ldflags '-extldflags "-static"' -v -o /fly/bin/monitor ./cmd/monitor
RUN CGO_ENABLED=1 GOOS=linux go build -ldflags '-extldflags "-static"' -v -o /fly/bin/start ./cmd/start
RUN CGO_ENABLED=1 GOOS=linux go build -ldflags '-extldflags "-static"' -v -o /fly/bin/cm ./cmd/cm
RUN CGO_ENABLED=1 GOOS=linux go build -ldflags '-extldflags "-static"' -v -o /fly/bin/api ./cmd/api
COPY ./bin/* /fly/bin/
COPY ./schedules.json /fly/schedules.json
COPY ./migrations /fly/migrations
# Start from Ubuntu 20.04 for the runtime stage
FROM ubuntu:22.04
# Avoid debconf warnings during the build
ENV DEBIAN_FRONTEND=noninteractive
# Install runtime dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
cron \
curl \
libsqlite3-dev \
sqlite3 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Copy the built binary from the builder stage
COPY --from=builder /fly/bin/* /usr/local/bin/
COPY --from=builder /fly/schedules.json /usr/local/share/
COPY --from=builder /fly/migrations /usr/local/share/migrations
# Set the CMD to your application
CMD ["start"]