Skip to content

Commit

Permalink
Merge pull request #107 from ublue-os/docker-fix
Browse files Browse the repository at this point in the history
fix: make the docker-dbox work
  • Loading branch information
castrojo authored Jun 22, 2024
2 parents dbef2cb + 65a2254 commit 942a53a
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 55 deletions.
57 changes: 22 additions & 35 deletions .github/workflows/build-docker-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand All @@ -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'
Expand Down
44 changes: 24 additions & 20 deletions apps/docker/Containerfile.docker
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"]
10 changes: 10 additions & 0 deletions apps/docker/distrobox.ini
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}"
8 changes: 8 additions & 0 deletions apps/incus/distrobox.ini
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}"

0 comments on commit 942a53a

Please sign in to comment.