Skip to content

added buildkit to build images without docker #32

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ FROM ubuntu:${ARG_UBUNTU_BASE_IMAGE_TAG}
WORKDIR /azp
ENV TARGETARCH=linux-x64
ENV VSTS_AGENT_VERSION=3.248.0
ENV BUILDKIT_VERSION=0.19.0


# To make it easier for build and release pipelines to run apt-get,
Expand All @@ -22,6 +23,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
iputils-ping \
jq \
lsb-release \
vim \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel that vim should be required here, we shall better keep it (docker image) small

software-properties-common \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get -y upgrade
Expand All @@ -34,6 +36,10 @@ RUN printenv \
RUN curl -LsS https://vstsagentpackage.azureedge.net/agent/${VSTS_AGENT_VERSION}/vsts-agent-${TARGETARCH}-${VSTS_AGENT_VERSION}.tar.gz | tar -xz


#Install buildkit
RUN curl -fsSL -o /tmp/buildkit.tar.gz https://github.com/moby/buildkit/releases/download/v${BUILDKIT_VERSION}/buildkit-v${BUILDKIT_VERSION}.linux-amd64.tar.gz
RUN tar -xzf /tmp/buildkit.tar.gz -C /tmp/
RUN mv /tmp/bin/* /usr/local/bin

# Install Azure CLI & Azure DevOps extension
RUN curl -LsS https://aka.ms/InstallAzureCLIDeb | bash \
Expand Down Expand Up @@ -92,7 +98,7 @@ RUN apt-get update && apt-get -y upgrade


# Copy start script
COPY ./start.sh .
COPY src/start.sh .
RUN chmod +x start.sh


Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Azure DevOps Agent on Kubernetes

The easiest and most effective method for creating and managing Azure DevOps agents on Kubernetes, without the need to spend time and effort wrestling with settings! Scale-out as much as is necessary and demolish them gracefully.
The easiest and most effective method for creating and managing Azure DevOps agents on Kubernetes, without the need to spend time and effort wrestling with settings! Scale-out as much as is necessary and demolish them gracefully

## Compatibility Matrix

Expand Down
67 changes: 67 additions & 0 deletions chart/templates/buildkit-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{{- if .Values.buildkit.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: buildkitd
name: buildkitd
spec:
replicas: 3
selector:
matchLabels:
app: buildkitd
template:
metadata:
labels:
app: buildkitd
annotations:
container.apparmor.security.beta.kubernetes.io/buildkitd: unconfined
# see buildkit/docs/rootless.md for caveats of rootless mode
spec:
containers:
- name: buildkitd
image: moby/buildkit:master-rootless
args:
- --addr
- unix:///run/user/1000/buildkit/buildkitd.sock
- --addr
- tcp://0.0.0.0:6942
- --oci-worker-no-process-sandbox
# the probe below will only work after Release v0.6.3
readinessProbe:
exec:
command:
- buildctl
- debug
- workers
initialDelaySeconds: 5
periodSeconds: 30
# the probe below will only work after Release v0.6.3
livenessProbe:
exec:
command:
- buildctl
- debug
- workers
initialDelaySeconds: 5
periodSeconds: 30
securityContext:
# Needs Kubernetes >= 1.19
seccompProfile:
type: Unconfined
# To change UID/GID, you need to rebuild the image
runAsUser: 1000
runAsGroup: 1000
ports:
- containerPort: 1234
volumeMounts:
# Dockerfile has `VOLUME /home/user/.local/share/buildkit` by default too,
# but the default VOLUME does not work with rootless on Google's Container-Optimized OS
# as it is mounted with `nosuid,nodev`.
# https://github.com/moby/buildkit/issues/879#issuecomment-1240347038
- mountPath: /home/user/.local/share/buildkit
name: buildkitd
volumes:
- name: buildkitd
emptyDir: {}
{{- end }}
14 changes: 14 additions & 0 deletions chart/templates/buildkit-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if .Values.buildkit.enabled }}
apiVersion: v1
kind: Service
metadata:
labels:
app: buildkitd
name: buildkitd
spec:
ports:
- port: 6942
protocol: TCP
selector:
app: buildkitd
{{- end }}
2 changes: 2 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ volumeMounts: []
# - name: dockersock
# mountPath: "/var/run/docker.sock"

buildkit:
enabled: false

serviceAccount:
# The name of the service account to use.
Expand Down