-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.ubuntu
More file actions
90 lines (76 loc) · 2.54 KB
/
Copy pathDockerfile.ubuntu
File metadata and controls
90 lines (76 loc) · 2.54 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Stage 1: Build PersysAgent
FROM ubuntu:22.04 AS builder
# Install build tools and dynamic dependencies
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
git \
pkg-config \
libssl-dev \
libcurl4-openssl-dev \
uuid-dev \
autoconf \
automake \
libtool \
python3 \
&& rm -rf /var/lib/apt/lists/*
# Build static jsoncpp 1.9.5
RUN git clone --depth 1 --branch 1.9.5 https://github.com/open-source-parsers/jsoncpp.git /tmp/jsoncpp \
&& cd /tmp/jsoncpp \
&& mkdir build && cd build \
&& cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_LIBS=ON -DCMAKE_INSTALL_PREFIX=/usr .. \
&& make -j$(nproc) \
&& make install \
&& ls -l /usr/lib/*/libjsoncpp.a \
&& rm -rf /tmp/jsoncpp
# Install standalone Asio
RUN git clone --depth 1 --branch asio-1-30-2 https://github.com/chriskohlhoff/asio.git /tmp/asio \
&& mkdir -p /usr/include \
&& cp -r /tmp/asio/asio/include/asio /usr/include/ \
&& cp /tmp/asio/asio/include/asio.hpp /usr/include/ \
&& ls -l /usr/include/asio.hpp \
&& rm -rf /tmp/asio
# Install Crow framework
RUN git clone --depth 1 --branch v1.2 https://github.com/CrowCpp/Crow.git /tmp/crow \
&& cd /tmp/crow \
&& mkdir build && cd build \
&& cmake .. -DCROW_BUILD_EXAMPLES=OFF -DCROW_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=/usr \
&& make -j$(nproc) \
&& make install \
&& ls -l /usr/include/crow.h \
&& rm -rf /tmp/crow
# Set working directory
WORKDIR /app
# Copy source files
COPY src/ ./src/
COPY CMakeLists.txt .
# Build PersysAgent with dynamic linking
RUN mkdir build && cd build \
&& cmake -DCMAKE_BUILD_TYPE=Release .. \
&& make -j$(nproc) \
&& strip --strip-unneeded PersysAgent \
&& ldd PersysAgent
# Stage 2: Runtime image
FROM ubuntu:22.04
# Install runtime dependencies (shared libraries)
RUN apt-get update && apt-get install -y \
docker.io \
ca-certificates \
libcurl4 \
libssl3 \
uuid \
libstdc++6 \
libgcc-s1 \
&& rm -rf /var/lib/apt/lists/*
# # Install docker-compose (static binary)
# RUN curl -L https://github.com/docker/compose/releases/download/v2.29.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose \
# && chmod +x /usr/local/bin/docker-compose
RUN apt-get update && apt-get install -y curl
# Copy compiled binary from builder
COPY --from=builder /app/build/PersysAgent /usr/local/bin/PersysAgent
# Set working directory
WORKDIR /app
# Expose port for API
EXPOSE 8080
# Command to run the agent
CMD ["/usr/local/bin/PersysAgent"]