Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build/
.git
.vscode
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ repos:
entry: scripts/run_lint.sh
language: script
pass_filenames: false
# Only run when C++ source, headers, CMake config, or lint config changes
files: \.(cpp|h|hpp|c|cc|cxx)$|CMakeLists\.txt$|\.clang-format$
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/refs/tags/v1.17.0.zip
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)
FetchContent_MakeAvailable(googletest)

Expand Down
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM ubuntu:25.10

# Avoid prompts from apt
ENV DEBIAN_FRONTEND=noninteractive

# Copy dependency script
COPY scripts/install_dependencies.sh /tmp/install_dependencies.sh

# Run dependency script
RUN /tmp/install_dependencies.sh && \
rm -rf /var/lib/apt/lists/* /tmp/install_dependencies.sh

# Set working directory
WORKDIR /app

# Copy project files
COPY . .

# Build the project
RUN mkdir -p build && cd build && \
cmake .. && \
make

# Set the entrypoint to the built executable
CMD ["./build/main"]
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,25 @@ With the above done, you should be ready to set up the needed environment.
git clone https://github.com/robert-7/Go-Board-Game.git && cd Go-Board-Game
```

## Building and Running
## Building and Running Locally

To build and run the binary, simply run `make && ./main`.
To clean up, run `make clean`.

## Building and Running with Docker

You can also run the game in a Docker container without installing dependencies on your host machine.

### Prerequisites

- Docker
- Docker Compose

### Instructions

1. **Allow X11 connections** (Linux): Since the game runs in a container but displays on your host screen, you need to allow the container to connect to your X server. Do so with: `xhost +local:docker```
1. **Build and Run**: Do so with `docker compose up --build`. The game window should appear on your screen.

## Linting

The repository uses the same commands locally and in CI. After installing the packages above, run:
Expand Down
12 changes: 12 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
go-game:
build: .
container_name: go-board-game
# Pass the DISPLAY environment variable to the container
environment:
- DISPLAY=${DISPLAY}
# Mount the X11 socket to allow the container to communicate with the X server
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix
# Use host networking to simplify X11 communication
network_mode: host
2 changes: 1 addition & 1 deletion scripts/install_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ run_with_sudo() {

run_with_sudo apt-get update
run_with_sudo apt-get install -y \
build-essential \
mesa-common-dev \
libglu1-mesa-dev \
libgl1-mesa-dev \
freeglut3-dev \
libglew-dev \
libdevil1c2 \
libdevil-dev \
cmake \
clang-tidy \
Expand Down