diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml deleted file mode 100644 index 711b383..0000000 --- a/.github/workflows/action.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: C/C++ CI - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Install Dependencies - run: sudo apt-get update && sudo apt-get install libcurl4-openssl-dev -y - - name: Apply Configure - run: ./configure - - name: Cmake With Fetching External Dependencies - run: cmake -DUSE_EXTERNAL_DPP=OFF -DUSE_EXTERNAL_JSON=OFF - - name: Make - run: make diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..c3946fc --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,36 @@ +name: Build + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + cmake: + name: CMake + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install Dependencies + run: | + sudo apt-get update + sudo apt-get install cmake make libcurl4-openssl-dev -y + - name: Apply Configure + run: ./configure + - name: CMake With Fetching External Dependencies + run: | + cmake -DUSE_EXTERNAL_DPP=OFF -DUSE_EXTERNAL_JSON=OFF + make + docker: + name: Docker + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Docker Build + run: | + docker build --platform=linux/amd64 -t asiantbd/crypto-prices-slash-bot . diff --git a/CMakeLists.txt b/CMakeLists.txt index 381c045..9bd21bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,3 +61,6 @@ set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON ) + +#Set Linker flags +set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++") diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..eda7266 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,65 @@ +# Build stage +FROM debian:trixie-slim AS build + +# Install necessary build tools and dependencies +RUN apt-get update && apt-get install -y \ + g++ \ + cmake \ + make \ + git \ + wget \ + libcurl4-openssl-dev \ + zlib1g-dev \ + ca-certificates \ + libssl-dev \ + libopus0 \ + libopus-dev \ + libsodium-dev \ + && rm -rf /var/lib/apt/lists/* + +# Set the working directory +WORKDIR /app + +# Copy the source code +COPY . . + +# Create build directory +RUN mkdir build + +# Build the project +WORKDIR /app/build +RUN wget -O libdpp.deb https://github.com/brainboxdotcc/DPP/releases/download/v10.0.23/libdpp-10.0.23-linux-x64.deb \ + && dpkg -i libdpp.deb \ + && ldconfig +RUN cmake -DUSE_EXTERNAL_JSON=OFF .. -B./ && make + +# Run stage +FROM debian:trixie-slim AS runtime + +# Install runtime dependencies & libraries +RUN apt-get update && apt-get install -y \ + ca-certificates \ + libopus0 \ + libopus-dev \ + libsodium-dev \ + libcurl4-openssl-dev \ + && rm -rf /var/lib/apt/lists/* + +# Create a non-root user +RUN useradd -m -s /bin/bash appuser + +# Set the working directory +WORKDIR /app + +# Add external library libdpp +COPY --from=build /app/build/libdpp.deb . +RUN dpkg -i libdpp.deb && rm libdpp.deb + +# Copy the built executable from the build stage +COPY --from=build --chown=appuser:appuser /app/build/asiantbd_bot . + +# Switch to non-root user +USER appuser + +# Set the entrypoint +ENTRYPOINT ["/app/asiantbd_bot"]