-
Notifications
You must be signed in to change notification settings - Fork 92
/
Copy pathDockerfile
63 lines (52 loc) · 1.61 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Backend build stage
FROM golang:1.23-bookworm AS backend
ARG VERSION
WORKDIR /src
# Install system dependencies first
RUN apt-get update && apt-get install -y \
curl \
autoconf \
automake \
libtool \
pkg-config \
git
# Clone and build libpostal (rarely changes)
RUN git clone https://github.com/openvenues/libpostal.git /src/libpostal
WORKDIR /src/libpostal
RUN ./bootstrap.sh && \
./configure && \
make -j$(shell nproc) && \
make install && \
ldconfig
# Download libpostal data (rarely changes)
RUN libpostal_data download all /usr/local/share/libpostal
# Copy go.mod and go.sum first to cache dependencies
COPY go.mod go.sum /src/
RUN go mod download
# Now copy the rest of the source code (frequently changes)
COPY . /src/
WORKDIR /src
RUN VERSION=${VERSION} GOTAGS="-tags libpostal" make build-server
# Final stage
FROM debian:bookworm
LABEL maintainer="Moov <[email protected]>"
# Install runtime dependencies
RUN apt-get update && \
apt-get install -y \
libssl3 \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Create necessary directories and copy libpostal files
RUN mkdir -p /usr/local/share/libpostal
COPY --from=backend /usr/local/lib/libpostal.so* /usr/local/lib/
COPY --from=backend /usr/local/lib/pkgconfig/libpostal.pc /usr/local/lib/pkgconfig/
COPY --from=backend /usr/local/share/libpostal/ /usr/local/share/libpostal/
RUN ldconfig
# Copy application files
COPY --from=backend /src/bin/server /bin/server
# Set environment variables
ENV LD_LIBRARY_PATH=/usr/local/lib
ENV LIBPOSTAL_DATA_DIR=/usr/local/share/libpostal
EXPOSE 8084
EXPOSE 9094
ENTRYPOINT ["/bin/server"]