aboutsummaryrefslogtreecommitdiff
path: root/Dockerfile
diff options
context:
space:
mode:
authorAnsari <ping@ansari.wtf>2026-03-30 00:13:13 +0530
committerfrosty <gabriel@bwaaa.monster>2026-03-30 03:01:16 +0300
commit9e6e76306471b3cc139ae68c0363ec95616d1b23 (patch)
treeffa49f70ede7a566370e0b20e220468d66df10e6 /Dockerfile
parent6b8a278b4f2973391b256eedf6add3d6a3516bc0 (diff)
downloadomnisearch-9e6e76306471b3cc139ae68c0363ec95616d1b23.tar.gz
docker: use multi-stage build to reduce image size
Diffstat (limited to 'Dockerfile')
-rw-r--r--Dockerfile61
1 files changed, 34 insertions, 27 deletions
diff --git a/Dockerfile b/Dockerfile
index 14b67b8..11aac36 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,39 +1,46 @@
-FROM alpine:latest
+# ---------- Build stage ----------
+FROM alpine:3.20 AS builder
-# Install required dependencies
RUN apk add --no-cache \
- libxml2-dev \
+ build-base \
curl-dev \
- shadow \
- git \
- make \
- gcc \
- musl-dev \
- pkgconf \
+ libxml2-dev \
openssl-dev \
- openrc
-
-# Clone and install beaker
-RUN git clone https://git.bwaaa.monster/beaker /tmp/beaker \
- && cd /tmp/beaker \
- && make \
- && make install \
- && rm -rf /tmp/beaker
+ git \
+ pkgconf
-# Import omnisearch source
WORKDIR /app
COPY . /app
-# Clone and install omnisearch
-RUN cd /app \
- && make \
- && make install-openrc
+RUN git clone https://git.bwaaa.monster/beaker /tmp/beaker && \
+ cd /tmp/beaker && \
+ make && make install && \
+ rm -rf /tmp/beaker
+
+RUN make clean && make && strip bin/omnisearch
+
+# ---------- Runtime stage ----------
+FROM alpine:3.20
+
+RUN apk add --no-cache \
+ libcurl \
+ libxml2 \
+ openssl
+
+WORKDIR /app
+
+# Copy only required artifacts
+COPY --from=builder /app/bin/omnisearch /app/omnisearch
+COPY --from=builder /usr/lib/libbeaker.so /usr/lib/libbeaker.so
+COPY --from=builder /app/templates /app/templates
+COPY --from=builder /app/static /app/static
+
+# Security: non-root user
+RUN adduser -D appuser && chmod +x /app/omnisearch
+USER appuser
-# Enable OpenRC and start the service
-RUN rc-update add omnisearch default
+ENV LD_LIBRARY_PATH=/usr/lib
-# Expose the default port
EXPOSE 5000
-# Start OpenRC and the service
-CMD sh -c "openrc default && touch /run/openrc/softlevel && omnisearch"
+CMD ["/app/omnisearch"]