-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
80 lines (62 loc) · 1.79 KB
/
Dockerfile
File metadata and controls
80 lines (62 loc) · 1.79 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Multi-stage build for libpostal-api
FROM rust:1.88.0-slim AS builder
# Install Node.js repository and update package lists
RUN apt-get update && apt-get install -y curl gnupg \
&& curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
# Install all dependencies (Node.js and build tools)
RUN apt-get update && apt-get install -y \
build-essential \
autoconf \
automake \
libtool \
libtool-bin \
pkg-config \
curl \
libcurl4-openssl-dev \
libssl-dev \
nodejs \
git \
cmake \
clang \
libclang-dev \
llvm-dev \
&& rm -rf /var/lib/apt/lists/*
# Verify libtool installation
RUN which libtool && libtool --version
# Set working directory
WORKDIR /app
# Copy all source files
COPY . .
# Build the application
RUN cargo build --release
# Runtime stage
FROM debian:bookworm-slim
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
libcurl4 \
&& rm -rf /var/lib/apt/lists/*
# Create app user
RUN useradd -r -s /bin/false app
# Create app directory
WORKDIR /app
# Set environment variable for libpostal data directory
ENV LIBPOSTAL_DATA_DIR=/app/data
# Copy the binary from builder stage
COPY --from=builder /app/target/release/libpostal-api /app/
COPY --from=builder /app/static /app/static
# Create data directory and download libpostal data
RUN mkdir -p data && chown -R app:app /app
# Switch to app user
USER app
# Pre-initialize libpostal data during build
# This downloads and initializes all required libpostal models and data
RUN ./libpostal-api --init-only
# Expose port
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3000/api/v1/health || exit 1
# Run the application
CMD ["./libpostal-api"]