-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
68 lines (51 loc) · 1.35 KB
/
Dockerfile
File metadata and controls
68 lines (51 loc) · 1.35 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
# Use a multi-stage build to reduce the final 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 \
zlib1g-dev \
libspdlog-dev \
nlohmann-json3-dev &&
rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy source code
COPY . .
# Build the project
RUN mkdir build && cd build &&
cmake .. &&
make -j$(nproc)
# Create the runtime image
FROM ubuntu:22.04
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
libssl1.1 \
zlib1g \
libspdlog1 &&
rm -rf /var/lib/apt/lists/*
# Copy the binary from the builder stage
COPY --from=builder /app/build/tradingbot /usr/local/bin/
# Create a non-root user
RUN useradd -m tradingbot
# Set up the working directory
WORKDIR /home/tradingbot
# Copy configuration files
COPY --from=builder /app/config /home/tradingbot/config
# Set ownership
RUN chown -R tradingbot:tradingbot /home/tradingbot
# Switch to non-root user
USER tradingbot
# Set environment variables
ENV LOG_LEVEL=info
ENV SIMULATION_MODE=true
# Create log directory
RUN mkdir -p /home/tradingbot/logs
# Expose ports if needed
# EXPOSE 8080
# Set the entrypoint
ENTRYPOINT ["/usr/local/bin/tradingbot"]
# Default command
CMD ["--config", "/home/tradingbot/config/config.json"]