Skip to content

Commit 70a3ed8

Browse files
committed
feat: run as host-user
1 parent c4f45a8 commit 70a3ed8

3 files changed

Lines changed: 39 additions & 76 deletions

File tree

README.md

Lines changed: 2 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,13 @@ This project targets Android 7 up to the most recent version.
1111
## Prerequisites
1212

1313
- [Podman](https://podman.io/docs/installation)
14-
- [Podman compose](https://github.com/containers/podman-compose?tab=readme-ov-file#generate-binary-using-dockerpodman-locally)
14+
- podman-docker or alias
1515
- or [Docker](https://docs.docker.com/engine/install)
16-
- [Docker Compose](https://docs.docker.com/compose/install)
17-
- [Docker Rootless](https://docs.docker.com/engine/security/rootless)
1816
- [SSH](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent)
1917
- [GitConfig](https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup)
2018
- ZRam (highly recommended): [Debian](https://wiki.debian.org/ZRam), [Fedora](https://github.com/systemd/zram-generator), [Ubuntu, Arch and others](https://wiki.archlinux.org/title/Zram)
2119

2220

23-
### Setting up permissions
24-
25-
First we need to find the UID, that is used for Docker/Podman.
26-
For Debian, Ubuntu and Gentoo this seems to be 100999 and on Fedora 52587,
27-
which should be $subUID+$containerUID-1 according to the [docker forums](https://forums.docker.com/t/map-more-uid-on-rootless-docker-and-mount-volume/102928/8).
28-
29-
3021
We need to manually create the required folders for the respective volumes
3122
```
3223
mkdir --parents ~/docker_droid/src ~/docker_droid/dotfiles ~/docker_droid/ccache ~/docker_droid/logs ~/docker_droid/keys
@@ -43,44 +34,6 @@ git clone https://github.com/SirRGB/dockdroid ~/docker_droid/minideb
4334

4435
Then we need to chown that directory to the Docker user:
4536

46-
#### Debian/Ubuntu
47-
```
48-
sudo chown --recursive 100999:"${UID}" ~/docker_droid/src ~/docker_droid/dotfiles ~/docker_droid/ccache ~/docker_droid/logs ~/docker_droid/keys
49-
```
50-
51-
#### Fedora
52-
```
53-
sudo chown --recursive 52587:"${UID}" ~/docker_droid/src ~/docker_droid/dotfiles ~/docker_droid/ccache ~/docker_droid/logs ~/docker_droid/keys
54-
```
55-
56-
#### Other
57-
(If you know a smarter way to do this please tell me,
58-
I know the available subuids can be found with `grep ${USER} < /etc/subuid | cut --delimiter=':' --fields=2`
59-
I just do not know if the container uid is predictable,
60-
it seems to be 1000 for debian/ubuntu and 100 for fedora)
61-
62-
Let other users read the directory
63-
```
64-
sudo chmod --recursive 507 ~/docker_droid/src ~/docker_droid/dotfiles ~/docker_droid/ccache ~/docker_droid/logs ~/docker_droid/keys
65-
```
66-
Run the first docker build
67-
```
68-
docker compose up --force-recreate --build
69-
```
70-
Wait until it starts syncing and stop using ctrl + c
71-
Find out the uid by running:
72-
```
73-
ls --numeric-uid-gid ~/docker_droid/src/Los15/.repo
74-
```
75-
Give ownership to the uid you found out:
76-
(replace the 1st UID)
77-
```
78-
sudo chown --recursive UID:"${UID}" ~/docker_droid/src ~/docker_droid/dotfiles ~/docker_droid/ccache ~/docker_droid/logs ~/docker_droid/keys
79-
```
80-
And remove the incomplete sync
81-
```
82-
sudo rm --recursive --force ~/docker_droid/src/Los15/
83-
```
8437
</details>
8538

8639

@@ -166,11 +119,7 @@ OTA_REPO_URL=git@github.com:user/ota_config
166119

167120
- After setting everything up you should do a test build with the default variables for testing. (Be sure to be in ~/docker_droid/minideb)
168121
```
169-
podman compose up --force-recreate --build
170-
```
171-
or
172-
```
173-
docker compose up --force-recreate --build
122+
bash dockdroid
174123
```
175124
176125

compose.yaml

Lines changed: 0 additions & 23 deletions
This file was deleted.

dockdroid

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
set -x
5+
6+
_build() {
7+
docker build --tag localhost/sirrgb/dockdroid:latest .
8+
}
9+
10+
_args() {
11+
#local volumes
12+
volumes=(
13+
-v ~/docker_droid/src:/droid_workdir/src
14+
-v ~/docker_droid/logs:/droid_workdir/logs
15+
-v ~/docker_droid/ccache:/mnt/ccache
16+
-v ~/docker_droid/keys:/droid_workdir/keys
17+
-v ~/docker_droid/dotfiles/.gitconfig:/droid_workdir/.gitconfig:ro
18+
-v ~/docker_droid/dotfiles/.ssh:/droid_workdir/.ssh:ro
19+
)
20+
# TODO >1 env-file
21+
env_file=~/docker_droid/minideb/target.env
22+
# "${@}"
23+
24+
if which podman; then
25+
args="--userns=keep-id"
26+
else
27+
args=("--user" "${UID}":"${GID}")
28+
fi
29+
}
30+
31+
_run() {
32+
docker run "${volumes[@]}" --env-file "${env_file}" "${args[@]}" localhost/sirrgb/dockdroid:latest
33+
}
34+
35+
_build
36+
_args
37+
_run

0 commit comments

Comments
 (0)