Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match current user's uid/gid at docker build time #2729

Merged

Conversation

dennisschagt
Copy link
Member

Resolves #2474

I made a previous attempt to fix uid/gid at runtime (#2698)
That turned out to require a lot of workarounds, partially due to limitations in cirrus options.

Specifying uid/gid at build time seems to cause a lot less issues (to be confirmed by a successful CI build and some more local testing)

@coveralls
Copy link

Coverage Status

coverage: 59.834%. remained the same
when pulling 1ec5025 on dennisschagt:alternative-docker-run-local
into c990101 on newsboat:master.

@dennisschagt
Copy link
Member Author

Seems to work fine now, checked locally by running the following shell script:

Build docker images and run tests

#!/usr/bin/bash

set -e

mkdir -p /tmp/local-smoketest/.cargo/registry

echo "Building docker images"

docker build \
    --tag=newsboat-code-formatting-tools \
    --file=docker/code-formatting-tools.dockerfile \
    docker

docker build \
    --tag=newsboat-i18nspector \
    --file=docker/i18nspector.dockerfile \
    docker

docker build \
    --build-arg UID="$(id -u)" \
    --build-arg GID="$(id -g)" \
    --tag=newsboat-build-tools-1804 \
    --file=docker/ubuntu_18.04-build-tools.dockerfile \
    docker

docker build \
    --build-arg UID="$(id -u)" \
    --build-arg GID="$(id -g)" \
    --tag=newsboat-i686-build-tools-1804 \
    --file=docker/ubuntu_18.04-i686.dockerfile \
    docker

docker build \
    --build-arg UID="$(id -u)" \
    --build-arg GID="$(id -g)" \
    --tag=newsboat-build-tools-2004 \
    --file=docker/ubuntu_20.04-build-tools.dockerfile \
    docker

docker build \
    --build-arg UID="$(id -u)" \
    --build-arg GID="$(id -g)" \
    --tag=newsboat-build-tools-2204 \
    --file=docker/ubuntu_22.04-build-tools.dockerfile \
    docker

docker build \
    --build-arg UID="$(id -u)" \
    --build-arg GID="$(id -g)" \
    --tag=newsboat-build-tools-2310 \
    --file=docker/ubuntu_23.10-build-tools.dockerfile \
    docker

echo "Running containers"

docker run \
    --rm \
    --mount type=bind,source="$(pwd)",target=/workspace \
    --user "$(id -u):$(id -g)" \
    newsboat-code-formatting-tools \
    make fmt

docker run \
    --rm \
    --mount type=bind,source="$(pwd)",target=/workdir \
    newsboat-i18nspector \
    make run-i18nspector

make distclean

docker run \
    -it \
    --rm \
    --mount type=bind,source=/tmp/local-smoketest/.cargo/registry,target=/home/builder/.cargo/registry \
    --mount type=bind,source="$(pwd)",target=/home/builder/src \
    newsboat-build-tools-1804 \
    make all check

make distclean

docker run \
    -it \
    --rm \
    --mount type=bind,source=/tmp/local-smoketest/.cargo/registry,target=/home/builder/.cargo/registry \
    --mount type=bind,source="$(pwd)",target=/home/builder/src \
    newsboat-i686-build-tools-1804 \
    make all check

make distclean

docker run \
    -it \
    --rm \
    --mount type=bind,source=/tmp/local-smoketest/.cargo/registry,target=/home/builder/.cargo/registry \
    --mount type=bind,source="$(pwd)",target=/home/builder/src \
    newsboat-build-tools-2004 \
    make all check

make distclean

docker run \
    -it \
    --rm \
    --mount type=bind,source=/tmp/local-smoketest/.cargo/registry,target=/home/builder/.cargo/registry \
    --mount type=bind,source="$(pwd)",target=/home/builder/src \
    newsboat-build-tools-2204 \
    make all check

make distclean

docker run \
    -it \
    --rm \
    --mount type=bind,source=/tmp/local-smoketest/.cargo/registry,target=/home/builder/.cargo/registry \
    --mount type=bind,source="$(pwd)",target=/home/builder/src \
    newsboat-build-tools-2310 \
    make all check

make distclean

@dennisschagt dennisschagt requested a review from Minoru April 7, 2024 19:32
@dennisschagt dennisschagt merged commit af9abc5 into newsboat:master Jun 2, 2024
39 checks passed
@dennisschagt dennisschagt deleted the alternative-docker-run-local branch June 2, 2024 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Figure out how to use our Docker images locally
2 participants