Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
tests
a.out
.idea
96 changes: 96 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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}
)
39 changes: 39 additions & 0 deletions web/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]