Skip to content
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

Add Dockerfile for testing/development #6

Open
wants to merge 3 commits into
base: main
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
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM ubuntu:focal-20210416

# Install binaries needed by devboxes
RUN apt-get update && \
apt-get install -y \
sudo \
ansible \
unzip \
fontconfig # fc-cache

# Enable snap inside container 🙈
# See https://github.com/ogra1/snapd-docker/blob/3a38d17a30d8295f6099b4e5769f54763e92ad4a/build.sh#L84
RUN apt-get install -y fuse snapd snap-confine squashfuse init && \
apt-get clean && \
dpkg-divert --local --rename --add /sbin/udevadm && \
ln -s /bin/true /sbin/udevadm
RUN systemctl enable snapd
VOLUME ["/sys/fs/cgroup"]
ENV container docker

# Use a mock instead of installing Gnome (1,6GB) inside the container
RUN echo 'echo gsettings mock' > /usr/bin/gsettings && chmod +x /usr/bin/gsettings

# This sets the password 'box'.
# Its a hashed value and was generated via "useradd dev" in an interactive shell and extracted from /etc/shadow
RUN useradd -m -p '$6$dcac3osTmIrBAB7p$o6iwk3hirHgS3lQdS2yrFDMmeZRe5JS9vJlra6Cam.AVedpUMtJWFiQNoE2eePeuIM4yzz5cbkBtnutDxY.7D/' -s /bin/bash dev && \
usermod -aG sudo dev

CMD [ "/sbin/init" ]
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,45 @@ Install ansible `sudo pacman -S ansible`
Just run the `devbox` script, on the first run it will ask some question to personalize the installed configurations.
After that it will ask for your sudo password and then apply the ansible playbook.

You can also test the whole bunch in an ephemeral docker container.

```shell
docker build -t devboxes .
docker run -v $(pwd):/home/dev/devboxes \
-it \
--tmpfs /run \
--tmpfs /run/lock \
--privileged \
-v /sys/fs/cgroup:/sys/fs/cgroup:ro \
-v /lib/modules:/lib/modules:ro \
--name devbox \
devboxes

#login with: dev / box
devboxes/devbox -e ansible_become_pass='box'

# Once ansible is done, explore the container as you like.
# After you're done, you'll have to kill it from another terminal:
docker stop devbox

# If you need the container again later just
docker start devbox
#login with: dev / box
docker attach devbox

# If you want to get rid of it for good
docker rm -f devbox
```

Please be aware that the `devbox` scripts loads several GB worth of data from the internet and that as a result the
container will have take several GB on your harddrive (7GB at the time of writing).

Note that it's not a sandboxed container, because devboxes relies on snap, which relies on systemd, which both are not
made for containers.
In general, less privileges than `--privileged` flag would suffice (see [snpad-docker](https://github.com/ogra1/snapd-docker/blob/3a38d17a30d8295f6099b4e5769f54763e92ad4a/build.sh#L110-L113)).
But, devboxes installs and runs docker (in this case in docker), which is what `--privileged` was made for, so its an obvious choice here.
Use it only for testing and development!

## Tags

Its also possible to only apply certain tags, e.g.
Expand Down