-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
64 lines (51 loc) Β· 1.73 KB
/
Dockerfile
File metadata and controls
64 lines (51 loc) Β· 1.73 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
# Multi-stage build for optimal image size
FROM ubuntu:22.04 AS builder
# Install build dependencies
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
git \
libssl-dev \
libpq-dev \
pkg-config \
curl \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy source code
COPY . .
# Create build directory and compile
RUN mkdir build && cd build && \
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local .. && \
make -j$(nproc) && \
make install
# Production stage
FROM ubuntu:22.04
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
libssl3 \
libpq5 \
ca-certificates \
&& rm -rf /var/lib/apt/lists/* \
&& groupadd -r securechat \
&& useradd -r -g securechat -s /bin/false securechat
# Copy binary and configuration
COPY --from=builder /usr/local/bin/securechat-server /usr/local/bin/
COPY --from=builder /usr/local/etc/securechat /etc/securechat
COPY --from=builder /app/scripts/docker-entrypoint.sh /usr/local/bin/
# Create necessary directories
RUN mkdir -p /var/log/securechat /var/lib/securechat/certs /var/lib/securechat/plugins \
&& chown -R securechat:securechat /var/log/securechat /var/lib/securechat \
&& chmod +x /usr/local/bin/docker-entrypoint.sh
# Copy default certificates (for development)
COPY certs/ /var/lib/securechat/certs/
# Expose ports
EXPOSE 8080 8081 9090
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8081/health || exit 1
# Switch to non-root user
USER securechat
# Set entrypoint
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["securechat-server", "--config", "/etc/securechat/server.json"]