Skip to content

Instantly share code, notes, and snippets.

@garethr
Created November 19, 2018 19:43
Show Gist options
  • Save garethr/f5c8c6878bbb4e20f32a90d3f68b0a8e to your computer and use it in GitHub Desktop.
Save garethr/f5c8c6878bbb4e20f32a90d3f68b0a8e to your computer and use it in GitHub Desktop.

Using Tilt from within a container.

Tilt is great, but it doesn't currently run on Windows. But can we run it in a container on Docker Desktop for Windows instead?

First build a Docker image for Tilt using the Dockerfile in this Gist.

$ docker build -t garethr/tilt .

And then run tilt up. Note that we mount the Docker socket and our Kubernetes configuration.

docker run --rm --net=host -it -v ~/.kube/config:/root/.kube/config -v /var/run/docker.sock:/var/run/docker.sock -v ${PWD}:/code  garethr/tilt up backend

Notes

This mainly works! Though a few issues arose that are worth looking into when time permits:

  • --watch doesn't work across the file mount
  • tilt demo crashes
  • on Docker Desktop the kubernetes config file will point to localhost. For this to work from within the container you currently have to change the server to host.docker.internal
apiVersion: v1
kind: Service
metadata:
name: tilt-service labels: app: tilt
spec:
type: LoadBalancer
ports:
- port: 5678
targetPort: 5678
selector:
app: tilt
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: tilt-deployment
spec:
selector:
matchLabels:
app: tilt
template:
metadata:
name: tilt-deployment
labels:
app: tilt
spec:
containers:
- name: backend
imagePullPolicy: Always
image: garethr/tilt-built-me
args: ["-text", "hello Til2"]
ports: - containerPort: 5678
FROM lachlanevenson/k8s-kubectl
RUN wget https://github.com/windmilleng/tilt/releases/download/v0.1.0/tilt.0.1.0.linux.x86_64.tar.gz && \
tar xvzf tilt.0.1.0.linux.x86_64.tar.gz && \
mv tilt /usr/local/bin/tilt
RUN tilt analytics opt in
RUN mkdir /code WORKDIR /code
ENTRYPOINT ["tilt"]
FROM hashicorp/http-echo
def backend():
img = static_build('Dockerfile.backend', 'garethr/tilt-built-me')
yaml = read_file('backend.yaml')
return k8s_service(img, yaml=yaml)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment