Quick Start
To build the Docker image, navigate to the directory containing theDockerfile and run:
raylib_container for easy reference.
Raylib is cloned and compiled directly from the official GitHub repository during the build, ensuring you always have the latest version available.
Multi-Stage Build Process
The Dockerfile uses a two-stage build to minimize the final image size while including all necessary development tools.Stage 1: Builder Stage
The first stage compiles Raylib from source:- Starts from Alpine Linux for minimal base size
- Installs all build dependencies (CMake, GCC, development headers)
- Cleans up package cache to reduce layer size
Raylib Compilation
Raylib is cloned and compiled with optimized settings:Build Configuration Details
Build Configuration Details
--depth=1: Shallow clone to reduce download size and timeCMAKE_BUILD_TYPE=Release: Optimized build with no debug symbolsPLATFORM=Desktop: Target desktop/Linux platformBUILD_SHARED_LIBS=ON: Build shared libraries (.so files)make -j$(nproc): Parallel compilation using all available CPU cores
Stage 2: Runtime Stage
The second stage creates the final image with only runtime dependencies:- Includes OpenGL/Mesa libraries for graphics rendering
- Adds X11 libraries for display server communication
- Includes GCC/G++ for compiling user code inside the container
- Installs
xeyesas a test utility for graphics verification
Copying Build Artifacts
The compiled Raylib libraries are copied from the builder stage:- Raylib shared libraries (.so files)
- Header files for development
- CMake configuration files
Build Command Variations
Basic Build
Standard build with default settings:Build with Tag
Create a tagged version for testing or versioning:Build with Pull and Cleanup
Force pull the latest base image and clean up intermediate containers:Flag Explanations:
--pull: Always attempt to pull a newer version of the base image--rm: Remove intermediate containers after successful build-f 'Dockerfile': Explicitly specify the Dockerfile path
No-Cache Build
Force a complete rebuild without using the cache:- You want the absolute latest Raylib version from GitHub
- Build artifacts might be corrupted
- Troubleshooting build issues
Rebuilding for Updates
You should rebuild the image when:Raylib Updates
Get the latest Raylib version from the official repository
Dockerfile Changes
After modifying the Dockerfile to add dependencies or change configuration
Base Image Updates
Pull security patches and updates from Alpine Linux
Troubleshooting
Fix corrupted or outdated images
Update Workflow
Build Troubleshooting
Common Build Issues
Error: “Cannot connect to the Docker daemon” Ensure Docker is running and you have proper permissions. Add your user to the docker group:Build Time Expectations
Typical build times:- First build: 3-8 minutes (depending on CPU and network speed)
- Cached rebuild: 30 seconds - 2 minutes
- No-cache rebuild: 3-8 minutes