mirror of
https://github.com/factoriotools/factorio-docker.git
synced 2025-07-03 23:48:05 +02:00
Compare commits
2 Commits
latest
...
fix-preset
Author | SHA1 | Date | |
---|---|---|---|
03589716dd | |||
8784845385 |
114
CLAUDE.md
Normal file
114
CLAUDE.md
Normal file
@ -0,0 +1,114 @@
|
||||
# CLAUDE.md
|
||||
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
|
||||
## Project Overview
|
||||
|
||||
This is a Docker image for running a Factorio headless server. It provides automated builds for multiple Factorio versions (stable and experimental) and supports both AMD64 and ARM64 architectures.
|
||||
|
||||
## Architecture
|
||||
|
||||
### Key Components
|
||||
|
||||
1. **Docker Image Build System**
|
||||
- `build.py` - Python script that builds Docker images from `buildinfo.json`
|
||||
- `docker/Dockerfile` - Main Dockerfile that creates the Factorio server image
|
||||
- `buildinfo.json` - Contains version info, SHA256 checksums, and tags for all supported versions
|
||||
- Supports multi-architecture builds (linux/amd64, linux/arm64) using Docker buildx
|
||||
|
||||
2. **Automated Updates**
|
||||
- `update.sh` - Checks for new Factorio releases and updates `buildinfo.json`
|
||||
- Updates README.md with new version tags
|
||||
- Commits changes and tags releases automatically
|
||||
- Run by GitHub Actions to keep images up-to-date
|
||||
|
||||
3. **Container Scripts**
|
||||
- `docker/files/docker-entrypoint.sh` - Main entrypoint that configures and starts the server
|
||||
- `docker/files/docker-update-mods.sh` - Updates mods on server start
|
||||
- `docker/files/docker-dlc.sh` - Manages DLC (Space Age) activation
|
||||
- `docker/files/scenario.sh` - Alternative entrypoint for launching scenarios
|
||||
- `docker/files/players-online.sh` - Checks if players are online (for watchtower integration)
|
||||
|
||||
4. **RCON Client**
|
||||
- `docker/rcon/` - C source for RCON client, built during Docker image creation
|
||||
- Allows sending commands to the running server
|
||||
|
||||
## Common Development Commands
|
||||
|
||||
### Building Images
|
||||
|
||||
```bash
|
||||
# Build a single architecture image locally
|
||||
python3 build.py
|
||||
|
||||
# Build and push multi-architecture images
|
||||
python3 build.py --multiarch --push-tags
|
||||
```
|
||||
|
||||
### Running the Container
|
||||
|
||||
```bash
|
||||
# Basic run command
|
||||
docker run -d \
|
||||
-p 34197:34197/udp \
|
||||
-p 27015:27015/tcp \
|
||||
-v /opt/factorio:/factorio \
|
||||
--name factorio \
|
||||
factoriotools/factorio
|
||||
|
||||
# Using docker-compose
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
### Linting
|
||||
|
||||
```bash
|
||||
# Lint Dockerfiles
|
||||
./lint.sh
|
||||
```
|
||||
|
||||
### Testing Updates
|
||||
|
||||
```bash
|
||||
# Check for new Factorio versions and update buildinfo.json
|
||||
./update.sh
|
||||
```
|
||||
|
||||
## Key Configuration
|
||||
|
||||
### Environment Variables
|
||||
- `LOAD_LATEST_SAVE` - Load the most recent save (default: true)
|
||||
- `GENERATE_NEW_SAVE` - Generate a new save if none exists (default: false)
|
||||
- `SAVE_NAME` - Name of the save file to load/create
|
||||
- `UPDATE_MODS_ON_START` - Update mods before starting (requires USERNAME/TOKEN)
|
||||
- `DLC_SPACE_AGE` - Enable/disable Space Age DLC (default: true)
|
||||
- `PORT` - UDP port for game server (default: 34197)
|
||||
- `RCON_PORT` - TCP port for RCON (default: 27015)
|
||||
|
||||
### Volume Structure
|
||||
All data is stored in a single volume mounted at `/factorio`:
|
||||
```
|
||||
/factorio/
|
||||
├── config/ # Server configuration files
|
||||
├── mods/ # Game modifications
|
||||
├── saves/ # Save games
|
||||
├── scenarios/ # Scenario files
|
||||
└── script-output/ # Script output directory
|
||||
```
|
||||
|
||||
## Version Management
|
||||
|
||||
The project maintains compatibility with multiple Factorio versions:
|
||||
- Latest experimental version gets the `latest` tag
|
||||
- Latest stable version gets the `stable` tag
|
||||
- Each version also gets specific tags (e.g., `2.0.55`, `2.0`, `2`)
|
||||
- Legacy versions back to 0.12 are supported
|
||||
|
||||
Version updates are automated via GitHub Actions that run `update.sh` periodically.
|
||||
|
||||
## Testing Changes
|
||||
|
||||
1. Modify `buildinfo.json` to test specific versions
|
||||
2. Run `python3 build.py` to build locally
|
||||
3. Test the container with your local data volume
|
||||
4. For production changes, ensure `update.sh` handles version transitions correctly
|
31
README.md
31
README.md
@ -203,6 +203,22 @@ sudo docker run -d \
|
||||
factoriotools/factorio
|
||||
```
|
||||
|
||||
To generate a new map with a specific preset (e.g., death-world):
|
||||
|
||||
```shell
|
||||
sudo docker run -d \
|
||||
-p 34197:34197/udp \
|
||||
-p 27015:27015/tcp \
|
||||
-v /opt/factorio:/factorio \
|
||||
-e LOAD_LATEST_SAVE=false \
|
||||
-e GENERATE_NEW_SAVE=true \
|
||||
-e SAVE_NAME=replaceme \
|
||||
-e PRESET=death-world \
|
||||
--name factorio \
|
||||
--restart=unless-stopped \
|
||||
factoriotools/factorio
|
||||
```
|
||||
|
||||
### Mods
|
||||
|
||||
Copy mods into the mods folder and restart the server.
|
||||
@ -321,6 +337,7 @@ These are the environment variables which can be specified at container run time
|
||||
| BIND | IP address (v4 or v6) the server listens on (IP\[:PORT]) | | 0.15+ |
|
||||
| RCON_PORT | TCP port the rcon server listens on | 27015 | 0.15+ |
|
||||
| SAVE_NAME | Name to use for the save file | _autosave1 | 0.17+ |
|
||||
| PRESET | Map generation preset when GENERATE_NEW_SAVE is true | | 0.17+ |
|
||||
| TOKEN | factorio.com token | | 0.17+ |
|
||||
| UPDATE_MODS_ON_START | If mods should be updated before starting the server | | 0.17+ |
|
||||
| USERNAME | factorio.com username | | 0.17+ |
|
||||
@ -330,6 +347,20 @@ These are the environment variables which can be specified at container run time
|
||||
|
||||
**Note:** All environment variables are compared as strings
|
||||
|
||||
#### PRESET Values
|
||||
|
||||
The `PRESET` environment variable is used when generating a new map (when `GENERATE_NEW_SAVE=true`). It corresponds to Factorio's built-in map generation presets. Common values include:
|
||||
|
||||
- `default` - Normal settings
|
||||
- `rich-resources` - Resources are more abundant
|
||||
- `marathon` - Recipes and technologies are more expensive
|
||||
- `death-world` - Biters are more aggressive and numerous
|
||||
- `death-world-marathon` - Combines death-world and marathon settings
|
||||
- `rail-world` - Resources are further apart, encouraging train usage
|
||||
- `ribbon-world` - Map height is limited for a unique challenge
|
||||
|
||||
If PRESET is not specified or left empty, the map will be generated using the settings from `map-gen-settings.json` and `map-settings.json` without a preset.
|
||||
|
||||
## Container Details
|
||||
|
||||
The philosophy is to [keep it simple](http://wiki.c2.com/?KeepItSimple).
|
||||
|
Reference in New Issue
Block a user