-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.prod
More file actions
42 lines (32 loc) · 1.17 KB
/
Copy pathDockerfile.prod
File metadata and controls
42 lines (32 loc) · 1.17 KB
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
# Stage 1: Build
FROM haskell:9.6-slim AS builder
WORKDIR /app
# Install libpq-dev for postgresql-simple
RUN apt-get update && apt-get install -y \
curl \
gnupg \
lsb-release \
pkg-config \
&& curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /usr/share/keyrings/postgresql.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/postgresql.gpg] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
&& apt-get update \
&& apt-get install -y libpq-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy cabal files first for dependency caching
COPY veritas.cabal cabal.project ./
RUN cabal update && cabal build --only-dependencies -j4 2>&1 || true
# Copy source and build the executable
COPY . .
RUN cabal build exe:veritas
# Copy the built binary to a known location
RUN cp $(cabal list-bin veritas) /app/veritas-bin
# Stage 2: Runtime
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y \
libgmp10 \
libpq5 \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/veritas-bin /usr/local/bin/veritas
EXPOSE 8080
CMD ["veritas"]