Skip to content

Commit

Permalink
enhance(ci): generate, export, store tar archive (termux#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
truboxl authored and licy183 committed Feb 27, 2024
1 parent 6189bbd commit 3eac6da
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 19 deletions.
44 changes: 35 additions & 9 deletions .github/workflows/docker_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Build and push Docker image

on:
push:
branches:
- master
pull_request:
schedule:
- cron: '0 2 * * 0'
Expand All @@ -14,6 +16,9 @@ env:
jobs:
main:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
CPU_ARCH:
Expand All @@ -39,24 +44,45 @@ jobs:
*) SYSTEM_TYPE=x86; PLATFORM_TAG="linux/amd64";;
esac
docker buildx build -t \
termux/termux-docker:${{ matrix.CPU_ARCH }} \
ghcr.io/termux-user-repository/termux-docker:${{ matrix.CPU_ARCH }} \
--platform "$PLATFORM_TAG" \
--build-arg BOOTSTRAP_ARCH=${{ matrix.CPU_ARCH }} \
--build-arg SYSTEM_TYPE="${SYSTEM_TYPE}" \
.
- name: Login to Docker Hub
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'termux/termux-docker'
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'termux-user-repository/termux-docker'
uses: docker/login-action@v3
with:
username: grimler
password: ${{ secrets.GRIMLER_DOCKER_TOKEN }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push to Docker Hub
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'termux/termux-docker'
- name: Push
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'termux-user-repository/termux-docker'
run: |
docker push termux/termux-docker:${{ matrix.CPU_ARCH }}
docker push ghcr.io/termux-user-repository/termux-docker:${{ matrix.CPU_ARCH }}
if [ ${{ matrix.CPU_ARCH }} = i686 ]; then
docker tag termux/termux-docker:i686 termux/termux-docker:latest
docker push termux/termux-docker:latest
docker tag ghcr.io/termux-user-repository/termux-docker:i686 ghcr.io/termux-user-repository/termux-docker:latest
docker push ghcr.io/termux-user-repository/termux-docker:latest
fi
- name: Export container as tar archive
if: always()
run: |
docker run \
--privileged \
--name termux-docker-${{ matrix.CPU_ARCH }} \
ghcr.io/termux-user-repository/termux-docker:${{ matrix.CPU_ARCH }} \
uname -a
docker stop termux-docker-${{ matrix.CPU_ARCH }}
docker export -o termux-docker-${{ matrix.CPU_ARCH }}.tar \
termux-docker-${{ matrix.CPU_ARCH }}
sha256sum termux-docker-${{ matrix.CPU_ARCH }}.tar
- name: Store tar archive
if: always()
uses: actions/upload-artifact@v4
with:
name: termux-docker-${{ matrix.CPU_ARCH }}-${{ github.sha }}
path: termux-docker-${{ matrix.CPU_ARCH }}.tar
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This will start interactive login shell. Everything will look like in a
normal Termux installation.

```.sh
docker run -it termux/termux-docker:latest
docker run -it ghcr.io/termux-user-repository/termux-docker:latest
```

When using the tag `latest`, container will be 32 bit (i686 architecture).
Expand Down Expand Up @@ -56,13 +56,13 @@ seccomp profile is required.
Variant with privileged container:

```.sh
docker run -it --privileged termux/termux-docker:aarch64
docker run -it --privileged ghcr.io/termux-user-repository/termux-docker:aarch64
```

Variant with seccomp unconfined profile:

```.sh
docker run -it --security-opt seccomp:unconfined termux/termux-docker:aarch64
docker run -it --security-opt seccomp:unconfined ghcr.io/termux-user-repository/termux-docker:aarch64
```

### Non-interactive execution of commands
Expand All @@ -73,7 +73,7 @@ command line.
Example:

```.sh
docker run -it --rm termux/termux-docker:latest bash -c "apt update && apt install -yq clang"
docker run -it --rm ghcr.io/termux-user-repository/termux-docker:latest bash -c "apt update && apt install -yq clang"
```

### Root shell
Expand All @@ -91,7 +91,7 @@ The provided images have 2 entry points:
Usage example:

```.sh
docker run -it --entrypoint /entrypoint_root.sh termux/termux-docker:latest
docker run -it --entrypoint /entrypoint_root.sh ghcr.io/termux-user-repository/termux-docker:latest
```

## Building image
Expand All @@ -117,4 +117,4 @@ There a number of known issues which may not be resolved:

* When running certain multi threaded program in 32bit containers, the PIDs can
balloon and easily exceed libc's limit. The only way to fix this is to set
`/proc/sys/kernel/pid_max` to 65535. See [termux-docker#40](https://github.com/termux/termux-docker/issues/40).
`/proc/sys/kernel/pid_max` to 65535. See [termux/termux-docker#40](https://github.com/termux/termux-docker/issues/40).
8 changes: 4 additions & 4 deletions build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ esac
for arch in "${ARCHITECTURES[@]}"; do
$SUDO $OCI build \
${OCI_ARG} \
-t 'termux/termux-docker:'"$arch" \
-t 'ghcr.io/termux-user-repository/termux-docker:'"$arch" \
-f Dockerfile \
--build-arg BOOTSTRAP_ARCH="$arch" \
--build-arg SYSTEM_TYPE="$SYSTEM_TYPE" \
.
if [ "${1-}" = "publish" ]; then
$SUDO $OCI push 'termux/termux-docker:'"$arch"
$SUDO $OCI push 'ghcr.io/termux-user-repository/termux-docker:'"$arch"
fi
done

if [ "$SYSTEM_TYPE" = "x86" ]; then
$SUDO $OCI tag termux/termux-docker:i686 termux/termux-docker:latest
$SUDO $OCI tag ghcr.io/termux-user-repository/termux-docker:i686 ghcr.io/termux-user-repository/termux-docker:latest
if [ "${1-}" = "publish" ]; then
$SUDO $OCI push 'termux/termux-docker:latest'
$SUDO $OCI push 'tghcr.io/termux-user-repository/termux-docker:latest'
fi
fi

0 comments on commit 3eac6da

Please sign in to comment.