-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
49 lines (34 loc) · 1.1 KB
/
Dockerfile
File metadata and controls
49 lines (34 loc) · 1.1 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
# Multi-stage build for C++ HTTP Server
FROM ubuntu:22.04 AS builder
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
libboost-all-dev \
nlohmann-json3-dev \
libssl-dev \
libsqlite3-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY . .
RUN cd bcrypt && mkdir -p build && cd build && cmake .. && make && cd ../..
RUN make clean && make
FROM ubuntu:22.04
# Install runtime dependencies only
RUN apt-get update && apt-get install -y \
libboost-system1.74.0 \
libboost-filesystem1.74.0 \
libssl3 \
libsqlite3-0 \
&& rm -rf /var/lib/apt/lists/*
RUN useradd -r -s /bin/false cppserver
WORKDIR /app
COPY --from=builder /app/server .
COPY --from=builder /app/templates ./templates
COPY --from=builder /app/config ./config
COPY --from=builder /app/bcrypt/build/libbcrypt.a ./bcrypt/build/
RUN chown -R cppserver:cppserver /app
USER cppserver
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8080/health || exit 1
CMD ["./server"]