From 72eed3c2bbfc1208860e35cc7bec070909e800f6 Mon Sep 17 00:00:00 2001 From: Jop Zitman Date: Tue, 10 Dec 2024 16:58:56 +0800 Subject: [PATCH] Add Dockerfile --- .dockerignore | 7 +++++++ CMakeLists.txt | 7 +++++-- Dockerfile | 24 ++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9810cc3 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +* +!certs/ +!src/ +!extern/ +!include/ +!src/ +!CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 9755bc5..3947cc1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.30) +cmake_minimum_required(VERSION 3.13) project(slipstream C) set(CMAKE_C_STANDARD 23) @@ -17,6 +17,9 @@ set(BUILD_TESTING OFF) set(PICOQUIC_ADDITIONAL_C_FLAGS "" CACHE STRING "Additional C flags for picoquic") +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE) +endif() if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") list(APPEND PICOQUIC_ADDITIONAL_C_FLAGS -Og) list(APPEND PICOQUIC_ADDITIONAL_CXX_FLAGS -Og) @@ -24,7 +27,7 @@ if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") else() list(APPEND PICOQUIC_ADDITIONAL_C_FLAGS -O3) list(APPEND PICOQUIC_ADDITIONAL_CXX_FLAGS -O3) -endif () +endif() add_subdirectory(extern/picoquic) diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..353beb4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM debian:bookworm-slim AS builder + +WORKDIR /usr/src/app + +# apt update without cache and install build-essential and cmake +RUN apt-get update && apt-get install -y build-essential cmake git pkg-config libssl-dev + +COPY . . + +RUN --mount=type=cache,target=/usr/src/app/cmake-cache \ + cmake -Bcmake-cache -H. && \ + cmake --build cmake-cache --target slipstream && mv cmake-cache/slipstream . + +FROM debian:bookworm-slim + +WORKDIR /usr/src/app + +RUN apt-get update && apt-get install -y libssl3 + +COPY ./certs/ ./certs/ + +COPY --from=builder /usr/src/app/slipstream . + +CMD ["/usr/src/app/slipstream"]