-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from ublue-os/docker-fix
fix: make the docker-dbox work
- Loading branch information
Showing
5 changed files
with
71 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,28 +36,6 @@ jobs: | |
pubkey: https://raw.githubusercontent.com/ublue-os/toolboxes/main/cosign.pub | ||
registry: ghcr.io/ublue-os | ||
|
||
# Build metadata | ||
- name: Image Metadata | ||
uses: docker/metadata-action@v5 | ||
id: meta | ||
with: | ||
images: | | ||
${{ env.IMAGE_NAME }} | ||
labels: | | ||
io.artifacthub.package.readme-url=https://raw.githubusercontent.com/ublue-os/boxkit/main/README.md | ||
# Build image using Buildah action | ||
- name: Build Image | ||
id: build_image | ||
uses: redhat-actions/buildah-build@v2 | ||
with: | ||
containerfiles: | | ||
./apps/docker/Containerfile.docker | ||
image: ${{ env.IMAGE_NAME }} | ||
tags: ${{ env.IMAGE_TAGS }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
oci: false | ||
|
||
# Workaround bug where capital letters in your GitHub username make it impossible to push to GHCR. | ||
# https://github.com/macbre/push-to-ghcr/issues/12 | ||
- name: Lowercase Registry | ||
|
@@ -66,20 +44,19 @@ jobs: | |
with: | ||
string: ${{ env.IMAGE_REGISTRY }} | ||
|
||
# Push the image to GHCR (Image Registry) | ||
- name: Push To GHCR | ||
uses: redhat-actions/push-to-registry@v2 | ||
if: github.event_name != 'pull_request' | ||
id: push | ||
env: | ||
REGISTRY_USER: ${{ github.actor }} | ||
REGISTRY_PASSWORD: ${{ github.token }} | ||
# Build metadata | ||
- name: Image Metadata | ||
uses: docker/metadata-action@v5 | ||
id: meta | ||
with: | ||
image: ${{ steps.build_image.outputs.image }} | ||
tags: ${{ steps.build_image.outputs.tags }} | ||
registry: ${{ steps.registry_case.outputs.lowercase }} | ||
username: ${{ env.REGISTRY_USER }} | ||
password: ${{ env.REGISTRY_PASSWORD }} | ||
images: | | ||
${{ steps.registry_case.outputs.lowercase }}/${{ env.IMAGE_NAME }} | ||
labels: | | ||
io.artifacthub.package.readme-url=https://raw.githubusercontent.com/ublue-os/boxkit/main/README.md | ||
tags: | | ||
${{ env.IMAGE_TAGS }} | ||
# Login to Contaier Registry if not a PR | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
if: github.event_name != 'pull_request' | ||
|
@@ -88,6 +65,16 @@ jobs: | |
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# Build and Push Image | ||
- name: Build and Push Image | ||
id: build_image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
push: ${{ github.event_name != 'pull_request' }} | ||
file: ./apps/docker/Containerfile.docker | ||
labels: ${{ steps.meta.outputs.labels }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
|
||
# Sign container | ||
- uses: sigstore/[email protected] | ||
if: github.event_name != 'pull_request' | ||
|
@@ -99,10 +86,10 @@ jobs: | |
wc -c cosign.key | ||
cosign sign -y --key cosign.key ${{ steps.registry_case.outputs.lowercase }}/${{ env.IMAGE_NAME }}@${TAGS} | ||
env: | ||
TAGS: ${{ steps.push.outputs.digest }} | ||
TAGS: ${{ steps.build_image.outputs.digest }} | ||
COSIGN_EXPERIMENTAL: false | ||
COSIGN_PRIVATE_KEY: ${{ secrets.SIGNING_SECRET }} | ||
|
||
- name: Echo outputs | ||
run: | | ||
echo "${{ toJSON(steps.push.outputs) }}" | ||
echo "${{ toJSON(steps.build_image.outputs) }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,27 @@ | ||
FROM ghcr.io/ublue-os/ubuntu-toolbox | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y \ | ||
ca-certificates \ | ||
curl \ | ||
systemd && \ | ||
mkdir -p /etc/apt/keyrings/ && \ | ||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o \ | ||
/etc/apt/keyrings/docker.asc && \ | ||
echo "deb [arch=$(dpkg --print-architecture) \ | ||
signed-by=/etc/apt/keyrings/docker.asc] \ | ||
https://download.docker.com/linux/ubuntu \ | ||
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" \ | ||
> /etc/apt/sources.list.d/docker.list && \ | ||
apt-get update && \ | ||
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin && \ | ||
apt-get clean && \ | ||
mkdir -p /var/lib/docker && \ | ||
groupmod -g 252 docker && \ | ||
systemctl enable docker.socket | ||
|
||
RUN <<EOF | ||
apt-get update | ||
DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates curl socat systemd | ||
mkdir -p /etc/apt/keyrings/ | ||
curl -fsSL https://get.docker.com -o /tmp/get-docker.sh | ||
sh /tmp/get-docker.sh | ||
apt-get clean | ||
mkdir -p /var/lib/docker | ||
rm -rf /var/lib/docker/** | ||
rm -f /usr/local/bin/docker | ||
cat > /usr/lib/systemd/system/docker-setup.service <<- EEOF | ||
[Unit] | ||
Description=Setup Docker Socket in /var/run/ | ||
After=docker.socket | ||
[Service] | ||
PassEnvironment=DOCKERGROUP | ||
ExecStart=/usr/bin/bash -c "while true; do sleep 1; /usr/bin/socat UNIX-LISTEN:/run/host/var/run/docker.sock,reuseaddr,fork,group=\${DOCKERGROUP:-docker},umask=007 UNIX-CONNECT:/var/run/docker.sock; done" | ||
[Install] | ||
WantedBy=sockets.target | ||
EEOF | ||
groupmod -g 252 docker | ||
systemctl enable docker-setup.service | ||
rm -rf /tmp /var/tmp | ||
EOF | ||
CMD ["/sbin/init"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[docker] | ||
image=ghcr.io/ublue-os/docker-distrobox:latest | ||
# Change the group name to your desired group. Otherwise falls back to docker @ gid 252 | ||
#additional_flags="-e DOCKERGROUP=$group" | ||
init=true | ||
nvidia=true | ||
root=true | ||
entry=false | ||
volume="/var/lib/docker" | ||
init_hooks="usermod -aG docker ${USER}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[incus] | ||
image=ghcr.io/ublue-os/incus-distrobox:latest | ||
init=true | ||
nvidia=true | ||
root=true | ||
entry=false | ||
volume="/var/lib/incus:/var/lib/incus /lib/modules:/lib/modules:ro" | ||
init_hooks="usermod -aG incus-admin ${USER}" |