Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

Commit

Permalink
docker: add basic docker support
Browse files Browse the repository at this point in the history
Signed-off-by: Maciej Pijanowski <maciej.pijanowski@3mdeb.com>

The problem with building for non-host arch as described in the:
go-debos#9 was resolved. Basic
arm64 example image building was tested on the Ubuntu 18.04.
This may enable more users to take advantage of the debos, as
usning it on non-Debian distros seems either impossible ot not
trivial.
  • Loading branch information
macpijan committed Aug 21, 2018
1 parent 5b74d5d commit f16ce70
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 0 deletions.
55 changes: 55 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
### first stage - builder ###
FROM golang:1.10 as builder

MAINTAINER Maciej Pijanowski <maciej.pijanowski@3mdeb.com>

ENV HOME=/scratch

# install debos build dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libglib2.0-dev \
libostree-dev \
&& rm -rf /var/lib/apt/lists/*

RUN go get -d github.com/go-debos/debos/cmd/debos
WORKDIR /go/src/github.com/go-debos/debos/
# RUN dep ensure
RUN GOOS=linux go build -a cmd/debos/debos.go

### second stage - runner ###
FROM debian:stretch-slim as runner

ARG DEBIAN_FRONTEND=noninteractive

# 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 \
debootstrap \
libostree-1-1 \
ca-certificates \
systemd-container \
binfmt-support \
patch \
# fakemachine runtime dependencies
qemu-system-x86 \
qemu-user-static \
busybox \
linux-image-amd64 \
systemd \
dbus \
&& rm -rf /var/lib/apt/lists/*

COPY --from=builder /go/src/github.com/go-debos/debos/debos /usr/bin/debos

# Bug description: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=806780
# It was fixed in debootstrap 1.0.96 while Stretch provides 1.0.89
COPY files/0001-Fix-multiple-components-usage-for-foreign.patch /usr/share/debootstrap
RUN cd /usr/share/debootstrap && \
patch < 0001-Fix-multiple-components-usage-for-foreign.patch && \
rm /usr/share/debootstrap/0001-Fix-multiple-components-usage-for-foreign.patch && \
apt-get autoremove -y patch && \
rm -rf /var/lib/apt/lists/*

WORKDIR /root
22 changes: 22 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Building
--------

```
./build.sh
```

Prerequisites
-------------

* `binfmt_misc` module loaded on the host machine:

```
modprobe binfmt_misc
```

Running
-------

```
./run.sh DEBOS_PARAMETERS
```
3 changes: 3 additions & 0 deletions docker/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

docker build -t debos .
50 changes: 50 additions & 0 deletions docker/files/0001-Fix-multiple-components-usage-for-foreign.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
>From 6621d8304cb79dcc6e07098caaf6eaa56fe8594a Mon Sep 17 00:00:00 2001
From: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Date: Tue, 1 Dec 2015 09:09:07 +0100
Subject: [PATCH] Fix multiple components usage for --foreign

commit e24e4b006736734e, bug #757819 made resolve_deps and
setup_available in the --foreign case. However this only worked when
using just one component as the USE_COMPONENTS variable is | delimited.

Translate the USE_COMPONENTS variable on the fly from | delimited to
space delimeted to allow multiple components to work again.

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
---
functions | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/functions b/functions
index 8bef5e6..64d76e4 100644
--- a/functions
+++ b/functions
@@ -1256,14 +1256,14 @@ resolve_deps () {
local ALLPKGS2="";
while [ "$PKGS" != "" ]; do
local NEWPKGS=""
- for c in ${COMPONENTS:-$USE_COMPONENTS}; do
+ for c in ${COMPONENTS:-$(echo ${USE_COMPONENTS} | tr '|' ' ')}; do
local path="dists/$SUITE/$c/binary-$ARCH/Packages"
local pkgdest="$TARGET/$($DLDEST pkg "$SUITE" "$c" "$ARCH" "$m1" "$path")"
NEWPKGS="$NEWPKGS $("$PKGDETAILS" GETDEPS "$pkgdest" $PKGS)"
done
PKGS=$(echo "$PKGS $NEWPKGS" | tr ' ' '\n' | sort | uniq)
local REALPKGS=""
- for c in ${COMPONENTS:-$USE_COMPONENTS}; do
+ for c in ${COMPONENTS:-$(echo ${USE_COMPONENTS} | tr '|' ' ')}; do
local path="dists/$SUITE/$c/binary-$ARCH/Packages"
local pkgdest="$TARGET/$($DLDEST pkg "$SUITE" "$c" "$ARCH" "$m1" "$path")"
REALPKGS="$REALPKGS $("$PKGDETAILS" PKGS REAL "$pkgdest" $PKGS | sed -n 's/ .*REAL.*$//p')"
@@ -1279,7 +1279,7 @@ resolve_deps () {
setup_available () {
local m1="${MIRRORS%% *}"

- for c in ${COMPONENTS:-$USE_COMPONENTS}; do
+ for c in ${COMPONENTS:-$(echo ${USE_COMPONENTS} | tr '|' ' ')}; do
local path="dists/$SUITE/$c/binary-$ARCH/Packages"
local pkgdest="$TARGET/$($DLDEST pkg "$SUITE" "$c" "$ARCH" "$m1" "$path")"
# XXX: What if a package is in more than one component?
--
2.6.2

8 changes: 8 additions & 0 deletions docker/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

docker run --rm \
-it \
--privileged \
-v ${PWD}:/root \
debos \
/bin/bash -c "debos $*"

0 comments on commit f16ce70

Please sign in to comment.