These Dockerfiles help get up and running with Godot 4.
The container can be built with
docker build --build-arg GODOT_VERSION=4.2.1 .
Godot projects can be built quickly by mounting volumes like:
mkdir -p build/linux
docker run -v "$(pwd):/app" ghcr.io/rivet-gg/godot-docker/godot:4.2.1 \
--export-release "Linux/X11" \
--headless ./build/linux/game.x86_64
See also godot-ci for Dockerfiles tailored for CI environments.
If running Godot as a dedicated server in production, we recommend using the following Dockerfile:
# MARK: Builder
FROM ghcr.io/rivet-gg/godot-docker/godot:4.2.1 AS builder
COPY . .
RUN mkdir -p build/linux \
&& godot -v --export-release "Linux/X11" --headless ./build/linux/game.x86_64
# MARK: Runner
FROM ubuntu:22.04
RUN apt update -y \
&& apt install -y expect-dev \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/build/linux/ /app
# Unbuffer output so the logs get flushed
CMD ["sh", "-c", "unbuffer /app/game.x86_64 --verbose --headless -- --server | cat"]