summaryrefslogtreecommitdiff
path: root/docker
diff options
context:
space:
mode:
Diffstat (limited to 'docker')
-rw-r--r--docker/Dockerfile80
-rw-r--r--docker/README.md36
-rw-r--r--docker/recipes.test.yml14
-rw-r--r--docker/tests/A/A/A/A/a.txt1
-rw-r--r--docker/tests/base.tar.gzbin0 -> 289 bytes
-rw-r--r--docker/tests/simple-recipe.yaml12
-rw-r--r--docker/unit-tests.test.yml10
7 files changed, 153 insertions, 0 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile
new file mode 100644
index 0000000..16059d9
--- /dev/null
+++ b/docker/Dockerfile
@@ -0,0 +1,80 @@
+# Global ARGs shared by all stages
+ARG DEBIAN_FRONTEND=noninteractive
+ARG GOPATH=/usr/local/go
+
+### first stage - builder ###
+FROM debian:buster-slim as builder
+
+ARG DEBIAN_FRONTEND
+ARG GOPATH
+ENV GOPATH=${GOPATH}
+
+# install debos build dependencies
+RUN apt-get update && \
+ apt-get install -y --no-install-recommends \
+ ca-certificates \
+ gcc \
+ git \
+ golang-go \
+ libc6-dev \
+ libostree-dev && \
+ rm -rf /var/lib/apt/lists/*
+
+# Build debos
+COPY . $GOPATH/src/github.com/go-debos/debos
+WORKDIR $GOPATH/src/github.com/go-debos/debos/cmd/debos
+RUN go get -d ./... && \
+ go get -d github.com/stretchr/testify && \
+ go install
+
+### second stage - runner ###
+FROM debian:buster-slim as runner
+
+ARG DEBIAN_FRONTEND
+ARG GOPATH
+
+# Set HOME to a writable directory in case something wants to cache things
+ENV HOME=/tmp
+
+LABEL org.label-schema.name "debos"
+LABEL org.label-schema.description "Debian OS builder"
+LABEL org.label-schema.vcs-url = "https://github.com/go-debos/debos"
+LABEL org.label-schema.docker.cmd 'docker run \
+ --rm \
+ --interactive \
+ --tty \
+ --device /dev/kvm \
+ --user $(id -u) \
+ --workdir /recipes \
+ --mount "type=bind,source=$(pwd),destination=/recipes" \
+ --security-opt label=disable'
+
+# debos runtime dependencies
+# ca-certificates is required to validate HTTPS certificates when getting debootstrap release file
+RUN apt-get update && \
+ apt-get install -y --no-install-recommends \
+ apt-transport-https \
+ binfmt-support \
+ bmap-tools \
+ btrfs-progs \
+ busybox \
+ bzip2 \
+ ca-certificates \
+ debootstrap \
+ dosfstools \
+ e2fsprogs \
+ gzip \
+ libostree-1-1 \
+ linux-image-amd64 \
+ parted \
+ pkg-config \
+ qemu-system-x86 \
+ qemu-user-static \
+ systemd \
+ systemd-container \
+ xz-utils && \
+ rm -rf /var/lib/apt/lists/*
+
+COPY --from=builder $GOPATH/bin/debos /usr/local/bin/debos
+
+ENTRYPOINT ["/usr/local/bin/debos"]
diff --git a/docker/README.md b/docker/README.md
new file mode 100644
index 0000000..7354617
--- /dev/null
+++ b/docker/README.md
@@ -0,0 +1,36 @@
+# debos
+
+Docker container for ['debos' tool](https://github.com/go-debos/debos).
+
+## Installation
+```
+docker pull godebos/debos
+```
+
+Debos needs virtualization to be enabled on the host and shared with the container.
+
+Check that `kvm` is enabled and writable by the user running the docker container by running ```ls /dev/kvm```
+
+## Usage
+/!\ This container should be used as an executable, i.e. there is no need to add `debos` after `godebos/debos`.
+
+To build `recipe.yaml`:
+```
+cd <PATH_TO_RECIPE_DIR>
+docker run --rm --interactive --tty --device /dev/kvm --user $(id -u) --workdir /recipes --mount "type=bind,source=$(pwd),destination=/recipes" --security-opt label=disable godebos/debos <RECIPE.yaml>
+```
+
+## Container build
+To build the debos container image from current git branch:
+```
+docker build -f docker/Dockerfile -t godebos/debos .
+```
+
+## Tests
+
+### unit tests
+Run unit test with debos-docker:
+```
+cd docker
+docker-compose -f unit-tests.test.yml up --build
+```
diff --git a/docker/recipes.test.yml b/docker/recipes.test.yml
new file mode 100644
index 0000000..18d4aca
--- /dev/null
+++ b/docker/recipes.test.yml
@@ -0,0 +1,14 @@
+version: '3.4'
+
+services:
+ sut:
+ build:
+ context: ..
+ dockerfile: docker/Dockerfile
+ target: runner
+ volumes:
+ - type: bind
+ source: ./tests
+ target: /recipes
+ working_dir: /recipes
+ command: simple-recipe.yaml
diff --git a/docker/tests/A/A/A/A/a.txt b/docker/tests/A/A/A/A/a.txt
new file mode 100644
index 0000000..7898192
--- /dev/null
+++ b/docker/tests/A/A/A/A/a.txt
@@ -0,0 +1 @@
+a
diff --git a/docker/tests/base.tar.gz b/docker/tests/base.tar.gz
new file mode 100644
index 0000000..cf787ff
--- /dev/null
+++ b/docker/tests/base.tar.gz
Binary files differ
diff --git a/docker/tests/simple-recipe.yaml b/docker/tests/simple-recipe.yaml
new file mode 100644
index 0000000..b4f99f2
--- /dev/null
+++ b/docker/tests/simple-recipe.yaml
@@ -0,0 +1,12 @@
+architecture: amd64
+
+actions:
+ - action: unpack
+ compression: gz
+ file: base.tar.gz
+
+ - action: overlay
+ source: A
+
+ - action: run
+ command: find ${ROOTDIR}
diff --git a/docker/unit-tests.test.yml b/docker/unit-tests.test.yml
new file mode 100644
index 0000000..b5c3e3f
--- /dev/null
+++ b/docker/unit-tests.test.yml
@@ -0,0 +1,10 @@
+version: '3.4'
+
+services:
+ sut:
+ build:
+ context: ..
+ dockerfile: docker/Dockerfile
+ target: builder
+ working_dir: /usr/local/go/src/github.com/go-debos/debos/actions
+ command: go test