This guide explains how to build your own Docker image from the source code.
- Docker installed on your system
- Git installed
- Basic command line knowledge
The repository includes a build.sh script that simplifies the Docker image building process.
Usage Examples:
# Build with default 'dev' tag
./build.sh
# Build with custom tag
./build.sh latest
# Build and publish to Docker Hub
./build.sh latest --publish
# Build production version
./build.sh v1.0.0Customizing for Your Registry:
Before building, edit the build.sh script to use your own Docker Hub username or private registry:
- Open
build.shin a text editor - Find the
IMAGE_NAMEvariable - Change
sples1/k4ryuu-cs2to your registry (e.g.,yourusername/cs2-server) - Save and run with your desired tag
What the script does:
- Builds the Docker image from the Dockerfile
- Tags it as
your-registry/image-name:TAG - Optionally pushes to Docker Hub with
--publishflag - Displays helpful next steps for testing
If you prefer to build manually:
# Navigate to the docker directory
cd docker
# Build the image
docker build -f KitsuneLab-Dockerfile -t your-registry/your-image:tag .
# Example
docker build -f KitsuneLab-Dockerfile -t myrepo/cs2-server:latest .Currently, the Dockerfile doesn't use build arguments, but you can modify it to add them.
# Login
docker login
# Push
docker push your-registry/your-image:tag# Login to your registry
docker login your-registry.com
# Tag for your registry
docker tag your-registry/your-image:tag your-registry.com/your-image:tag
# Push
docker push your-registry.com/your-image:tagAfter building and pushing your image:
Recommendation: Use Docker Hub with a private repository to protect your customizations.
- Go to Admin → Nests → Your Nest → Eggs
- Edit the KitsuneLab CS2 Egg
- In Docker Images section, add your custom image:
"My Custom Image": "your-registry/your-image:tag"
- Save changes
- In your server's Startup tab, select your custom image
If using a private Docker Hub repository or private registry, you must authenticate on all Pterodactyl nodes:
# SSH into each Pterodactyl node
ssh root@your-node.com
# Login to Docker Hub (or your private registry)
docker login
# Enter your credentials when promptedImportant: Pterodactyl nodes need registry access to pull private images. Without authentication, container creation will fail with "pull access denied" errors.
Edit docker/KitsuneLab-Dockerfile:
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && \
apt install -y iproute2 jq unzip expect rsync cron curl gawk \
your-new-package \
another-package && \
apt-get clean- Create your script in
docker/scripts/ordocker/utils/ - Ensure it's copied in the Dockerfile:
COPY ./scripts/* /scripts/
COPY ./utils/* /utils/- Make it executable:
RUN chmod +x /scripts/*.sh && \
chmod +x /utils/*.shEdit docker/entrypoint.sh to change startup behavior.
The build.sh script provides a streamlined building experience with multiple options:
Usage:
./build.sh [TAG] [options]Options:
-t, --tag TAG- Set the Docker tag (default:dev)-P, --publish- Automatically push to registry after build-h, --help- Show usage information
Examples:
./build.sh # Build with 'dev' tag
./build.sh release # Build with 'release' tag
./build.sh -t 1.2.3 -P # Build version 1.2.3 and pushThe script provides a modern, colorful output with progress indicators:
──────────────────────────────────────────────────────
KitsuneLab CS2 Docker Image Builder
──────────────────────────────────────────────────────
Image: sples1/k4ryuu-cs2:latest
==> Building Docker image
🔷 INFO Dockerfile: KitsuneLab-Dockerfile
🔷 INFO Tag: latest
Building image
⠋ Building image
[✓] DONE Building image finished in 45s
🔷 INFO Image size: 1.23 GB
==> Next steps
To push to Docker Hub, run:
docker push sples1/k4ryuu-cs2:latest
Features:
- Animated spinner during build
- Build time tracking
- Automatic image size calculation
- Color-coded status messages ([SUCCESS], [ERROR], [WARNING])
- Optional auto-publish with
--publishflag
To build for multiple architectures (AMD64, ARM64):
# Create a builder
docker buildx create --name cs2-builder --use
# Build for multiple platforms
docker buildx build \
--platform linux/amd64,linux/arm64 \
-f docker/KitsuneLab-Dockerfile \
-t your-registry/your-image:tag \
--push \
.Create .github/workflows/build.yml:
name: Build Docker Image
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: ./docker
file: ./docker/KitsuneLab-Dockerfile
push: true
tags: |
sples1/k4ryuu-cs2:${{ github.ref_name }}
sples1/k4ryuu-cs2:latest# Clear Docker build cache
docker builder prune
# Rebuild without cache
docker build --no-cache -f docker/KitsuneLab-Dockerfile -t your-image:tag .# Ensure build script is executable
chmod +x build.sh
# Ensure scripts are accessible
chmod +x docker/scripts/*.sh
chmod +x docker/utils/*.shOptimize your Dockerfile:
- Combine RUN commands
- Remove unnecessary packages
- Use
.dockerignorefile - Clean up after installations
- Version your builds - Use semantic versioning tags
- Test before pushing - Always test locally first
- Use multi-stage builds - If adding compilation steps
- Document changes - Update CHANGELOG for custom builds
- Keep base image updated - Regularly pull SteamRT updates
- Minimize layers - Combine commands where possible
If you've made improvements:
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
See Contributing Guide for details.
Need help with building?
- Report an Issue
- Check existing build-related issues