diff --git a/.gitignore b/.gitignore index 07e019e..bd440e7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ tests a.out +.idea \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..5efc2b5 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,96 @@ +# ------------------------------------------------------------ +# Minimum CMake version required +# ------------------------------------------------------------ +cmake_minimum_required(VERSION 3.10) + +# ------------------------------------------------------------ +# Project definition +# ------------------------------------------------------------ +# - Name: cppq +# - Version: 0.1 +# - Language: C++ +project(cppq VERSION 0.1 LANGUAGES CXX) + +# ------------------------------------------------------------ +# C++ standard configuration +# ------------------------------------------------------------ +# Require modern C++17 support (no compiler extensions) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +# ------------------------------------------------------------ +# Header-only library definition +# ------------------------------------------------------------ +# This creates an INTERFACE library — no compiled code, +# just header cppq.hpp +add_library(cppq INTERFACE) + +# Make headers in the project root available to anything +# that links to cppq +target_include_directories(cppq INTERFACE + ${CMAKE_CURRENT_SOURCE_DIR} +) + +# ------------------------------------------------------------ +# Dependency discovery +# ------------------------------------------------------------ +# We’ll use pkg-config to find libraries that don’t provide +# native CMake config files. + +# Make sure pkg-config is available +find_package(PkgConfig REQUIRED) + +# Find libuuid (used for generating UUIDs) +pkg_check_modules(UUID REQUIRED uuid) + +# Find hiredis (Redis C client library) +pkg_check_modules(HIREDIS REQUIRED hiredis) + +# Find Catch2 v3 (C++ testing framework) +find_package(Catch2 3 REQUIRED) + +# Add nlohmann_json dependency for tests +find_package(nlohmann_json REQUIRED) + +# ------------------------------------------------------------ +# Build the unit test executable +# ------------------------------------------------------------ +# - Compiles tests.cpp +# - Links against cppq, hiredis, uuid, and Catch2 +add_executable(tests tests.cpp) + +# Add include directories from pkg-config results +target_include_directories(tests PRIVATE + ${UUID_INCLUDE_DIRS} + ${HIREDIS_INCLUDE_DIRS} +) + +# Link required libraries +target_link_libraries(tests PRIVATE + cppq # our header-only library + ${UUID_LIBRARIES} # libuuid + ${HIREDIS_LIBRARIES} # hiredis + Catch2::Catch2WithMain # Catch2 test runner + nlohmann_json::nlohmann_json # json dep +) + +# ------------------------------------------------------------ +# Build the example executable +# ------------------------------------------------------------ +# - Compiles example.cpp +# - Links only with cppq, hiredis, and uuid +add_executable(example example.cpp) + +# Include hiredis and uuid headers +target_include_directories(example PRIVATE + ${UUID_INCLUDE_DIRS} + ${HIREDIS_INCLUDE_DIRS} +) + +# Link with cppq and dependencies +target_link_libraries(example PRIVATE + cppq + ${UUID_LIBRARIES} + ${HIREDIS_LIBRARIES} +) diff --git a/web/Dockerfile b/web/Dockerfile new file mode 100644 index 0000000..2d2a2e6 --- /dev/null +++ b/web/Dockerfile @@ -0,0 +1,39 @@ +# Use the official Node.js 20 LTS image as the base +FROM node:20-alpine AS builder + +# Set working directory +WORKDIR /app + +# Install dependencies +COPY package.json package-lock.json* ./ +RUN npm ci + +# Copy the rest of the source code +COPY . . + +# Build the Next.js app +RUN npm run build + +# Production image +FROM node:20-alpine AS runner + +WORKDIR /app + +# Install only production dependencies +COPY package.json package-lock.json* ./ +RUN npm ci --omit=dev + +# Copy the built Next.js app and public files +COPY --from=builder /app/.next ./.next +COPY --from=builder /app/public ./public +COPY --from=builder /app/next.config.ts ./ +COPY --from=builder /app/node_modules ./node_modules + +# Set environment variable +ENV NODE_ENV=production + +# Expose the default Next.js port +EXPOSE 3000 + +# Start the app +CMD ["npm", "start"]