-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
64 lines (49 loc) · 2.36 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
# This is a multi-stage Docker build that uses the golang:1.21-bullseye image to
# a) To compile govarnam the shared .so lib and the cli bin
# b) To compile varnamd-govarnam HTTP server that depends on the lib
# c) To copy the results into a debian:bullseye-slim image with glibc
###### Build stage
FROM golang:1.21-bullseye AS build
WORKDIR /app
# Install dependencies for git and other utilities
RUN apt-get update && apt-get install -y --no-install-recommends \
libc-dev gcc git pkg-config sqlite3 && \
rm -rf /var/lib/apt/lists/*
# Download and compile the shared libgovarnam.so lib
RUN git clone https://github.com/varnamproject/govarnam.git
RUN cd govarnam && go build -tags "fts5" -buildmode=c-shared -o libgovarnam.so
# Install the lib.
RUN mkdir -p /usr/local/include /usr/local/lib/pkgconfig
RUN cp govarnam/libgovarnam.so /usr/local/lib/ \
&& cp -R govarnam/c-shared* /usr/local/include/ \
&& cp govarnam/libgovarnam.h /usr/local/include/ \
&& sed "s#@INSTALL_PREFIX@#/usr/local#g" govarnam/govarnam.pc.in > /usr/local/lib/pkgconfig/govarnam.pc
# Build varnamcli.
RUN cd govarnam && go build -o varnamcli -ldflags "-s -w" ./cli
# Download and compile the varnamd HTTP server.
RUN git clone https://github.com/varnamproject/varnamd-govarnam.git
RUN cd varnamd-govarnam && go build -o varnamd-govarnam
###### Runtime stage
FROM debian:bullseye-slim
# Copy the deps and the binaries from the build stage.
COPY --from=build /usr/local/lib/libgovarnam.so /usr/local/lib/
COPY --from=build /usr/local/include/c-shared* /usr/local/include/
COPY --from=build /usr/local/include/libgovarnam.h /usr/local/include/
COPY --from=build /usr/local/lib/pkgconfig/govarnam.pc /usr/local/lib/pkgconfig/
# Binaries.
RUN mkdir -p /varnamd/ui
COPY --from=build /app/govarnam/varnamcli /usr/local/bin/
COPY --from=build /app/varnamd-govarnam/varnamd-govarnam /usr/local/bin/varnamd
COPY --from=build /app/varnamd-govarnam/ui /varnamd/ui/
COPY --from=build /app/varnamd-govarnam/config.toml /varnamd/
# Setup the deps.
ENV LD_LIBRARY_PATH=/usr/local/lib
RUN apt-get update && apt-get install -y --no-install-recommends libc-dev sqlite3 && \
ldconfig /usr/local/lib && \
apt-get remove --purge -y libc-dev && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*
EXPOSE 8123
WORKDIR /varnamd
ENTRYPOINT ["/usr/local/bin/varnamd"]
CMD ["--config", "/varnamd/config.toml"]