-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: add Dockerfile, update CMake build definition * ci: update build action, add docker build * ci: update build action format
- Loading branch information
Showing
4 changed files
with
104 additions
and
21 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] |