Improve Dockerfile (#3403)

This tries to fix a few issues I've been running into with the
Dockerfile:

`ln -s /usr/local/go/bin/go ~/go/bin/go` doesn't seem to put go on the
path.
We don't run `rustup` so when we try to run any rust code it complains
about the toolchain.
Running any go for the first time triggers a ton of downloads.

For me this now allows building out of the box instead of several extra
steps.
This commit is contained in:
sozud authored and GitHub committed 2026-07-22 08:41:35 +10:00
1 parent cdc97c36f1
commit 735089aac9
1 file changed
+18 -4
+18 -4
View File
@@ -7,7 +7,7 @@
# docker run --name sotn-work -it -v $(pwd):/sotn -v sotn_venv:/sotn/.venv -v sotn_build:/sotn/build sotn-build
#
# 3. you are now ready to build and work on SOTN
# make expected
# ./sotn.sh build
#
# 4. from now on, to re-use the same container execute the following:
# docker start -ai sotn-work
@@ -18,6 +18,12 @@ COPY /tools/requirements-debian.txt /tools/requirements-debian.txt
COPY /tools/requirements-python.txt /tools/requirements-python.txt
COPY --from=golang:1.24-bookworm /usr/local/go/ /usr/local/go/
# go and the rustup-managed cargo proxies must be on PATH for every shell
ENV PATH=/usr/local/go/bin:/home/ubuntu/.cargo/bin:$PATH
ENV GOTOOLCHAIN=local
ENV CARGO_HOME=/home/ubuntu/.cargo
ENV RUSTUP_HOME=/home/ubuntu/.rustup
WORKDIR /sotn
RUN apt-get update && \
apt-get install -y $(cat /tools/requirements-debian.txt) && \
@@ -33,11 +39,19 @@ RUN apt-get update && \
USER ubuntu
RUN mkdir -p /sotn/.venv /sotn/build && \
mkdir -p ~/go/bin && \
ln -s /usr/local/go/bin/go ~/go/bin/go && \
git config --global --add safe.directory /sotn && \
rustup set profile minimal && \
rustup default stable && \
git config --global --add safe.directory '*' && \
python3 -m venv .venv && \
. .venv/bin/activate && \
pip3 install -r /tools/requirements-python.txt
# Warm the go module cache so the first `./sotn.sh` invocation does not have to
# resolve the whole workspace over the network.
COPY --chown=ubuntu:ubuntu go.work go.work.sum ./
COPY --chown=ubuntu:ubuntu tools/gfxsotn/go.* tools/gfxsotn/
COPY --chown=ubuntu:ubuntu tools/sotn-assets/go.* tools/sotn-assets/
COPY --chown=ubuntu:ubuntu tools/sotn-disk/go.* tools/sotn-disk/
RUN go mod download all && rm -rf /sotn/go.work /sotn/go.work.sum /sotn/tools
ENTRYPOINT ["/bin/bash"]