-
Notifications
You must be signed in to change notification settings - Fork 93
/
Dockerfile
79 lines (65 loc) · 2 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# 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
# Frontend build stage
FROM node:22-bookworm as frontend
ARG VERSION
WORKDIR /watchman/
# Copy package files first to cache dependencies
COPY webui/package*.json webui/
WORKDIR /watchman/webui/
RUN npm install --legacy-peer-deps
# Copy and build frontend source (frequently changes)
COPY webui/ ./
RUN npm run build
# 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
COPY --from=frontend /watchman/webui/build/ /watchman/
# Set environment variables
ENV WEB_ROOT=/watchman/
ENV LD_LIBRARY_PATH=/usr/local/lib
ENV LIBPOSTAL_DATA_DIR=/usr/local/share/libpostal
EXPOSE 8084
EXPOSE 9094
ENTRYPOINT ["/bin/server"]