Browse Source

Merge pull request #55 from estenberg/move-container-env-to-root

Move container env to root
1.1.x
Eystein Måløy Stenberg 6 years ago
committed by GitHub
parent
commit
375ba4a1d4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 0
      .dockerignore
  2. 23
      Dockerfile
  3. 76
      README.md
  4. 9
      docker-build
  5. 11
      docker-entrypoint.sh
  6. 13
      docker-mender-convert
  7. 74
      docker/README.md
  8. 7
      docker/docker-build
  9. 33
      docker/docker-entrypoint.sh
  10. 16
      docker/docker-mender-convert

0
docker/.dockerignore → .dockerignore

23
docker/Dockerfile → Dockerfile

@ -52,10 +52,27 @@ RUN wget https://dl.google.com/go/go$GOLANG_VERSION.linux-amd64.tar.gz \
&& tar -C /usr/local -xzf go$GOLANG_VERSION.linux-amd64.tar.gz \ && tar -C /usr/local -xzf go$GOLANG_VERSION.linux-amd64.tar.gz \
&& echo export PATH=$PATH:/usr/local/go/bin >> /root/.bashrc && echo export PATH=$PATH:/usr/local/go/bin >> /root/.bashrc
# TODO: support selecting tag of mender-convert with MENDER_CONVERT_VERSION ARG mender_client_version
# TODO: consider lighter way to download to avoid git dependency
RUN git clone https://github.com/mendersoftware/mender-convert.git
ENV MENDER_CLIENT_VERSION=$mender_client_version
# NOTE: we are assuming generic ARM board here, needs to be extended later
ENV PATH "$PATH:/usr/local/go/bin:/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin"
ENV GOPATH "/root/go"
RUN go get github.com/mendersoftware/mender
WORKDIR $GOPATH/src/github.com/mendersoftware/mender
RUN git checkout $MENDER_CLIENT_VERSION
RUN env CGO_ENABLED=1 \
CC=arm-linux-gnueabihf-gcc \
GOOS=linux \
GOARCH=arm make build
RUN cp $GOPATH/src/github.com/mendersoftware/mender/mender /
WORKDIR /
COPY docker-entrypoint.sh /usr/local/bin/ COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]

76
README.md

@ -13,6 +13,82 @@ image by restructuring partition table and injecting the necessary files.
To start using Mender, we recommend that you begin with the Getting started To start using Mender, we recommend that you begin with the Getting started
section in [the Mender documentation](https://docs.mender.io/). section in [the Mender documentation](https://docs.mender.io/).
## Docker environment for mender-convert
In order to correctly set up partitions and bootloaders, mender-convert has many dependencies,
and their version and name vary between Linux distributions.
To make using mender-convert easier, a reference setup using a Ubuntu 18.04 Docker container
is provided.
You need to [install Docker Engine](https://docs.docker.com/install) to use this environment.
### Build the mender-convert container image
To build a container based on Ubuntu 18.04 with all required dependencies for mender-convert,
copy this directory to your workstation and change the current directory to it.
Then run
```bash
./docker-build
```
This will create a container image you can use to run mender-convert.
### Use the mender-convert container image
Create a directory `input` under the directory where you copied these files (`docker-build`, `docker-mender-convert`, etc.):
```bash
mkdir input
```
Then put your raw disk image into `input/`, e.g.
```bash
mv ~/Downloads/2018-11-13-raspbian-stretch.img input/2018-11-13-raspbian-stretch.img
```
You can run mender-convert from inside the container with your desired options, e.g.
```bash
DEVICE_TYPE="raspberrypi3"
RAW_DISK_IMAGE="input/2018-11-13-raspbian-stretch.img"
ARTIFACT_NAME="2018-11-13-raspbian-stretch"
MENDER_DISK_IMAGE="2018-11-13-raspbian-stretch.sdimg"
TENANT_TOKEN="<INSERT-TOKEN-FROM Hosted Mender>"
./docker-mender-convert from-raw-disk-image \
--raw-disk-image $RAW_DISK_IMAGE \
--mender-disk-image $MENDER_DISK_IMAGE \
--device-type $DEVICE_TYPE \
--mender-client /mender \
--artifact-name $ARTIFACT_NAME \
--bootloader-toolchain arm-linux-gnueabihf \
--server-url "https://hosted.mender.io" \
--tenant-token $TENANT_TOKEN
```
Note that the default Mender client is the latest stable and cross-compiled for generic ARM boards,
which should work well in most cases. If you would like to use a different Mender client,
place it in `input/` and adjust the `--mender-client` argument.
Conversion will take 10-15 minutes, depending on your storage and resources available.
You can watch `output/build.log` for progress and diagnostics information.
After it finishes, you can find your images in the `output` directory on your host machine!
### Known issues
* BeagleBone images might not convert properly using this docker envirnoment due to permission issues: `mount: /mender-convert/output/embedded/rootfs: WARNING: device write-protected, mounted read-only.`
## Contributing ## Contributing
We welcome and ask for your contribution. If you would like to contribute to Mender, please read our guide on how to best get started [contributing code or documentation](https://github.com/mendersoftware/mender/blob/master/CONTRIBUTING.md). We welcome and ask for your contribution. If you would like to contribute to Mender, please read our guide on how to best get started [contributing code or documentation](https://github.com/mendersoftware/mender/blob/master/CONTRIBUTING.md).

9
docker-build

@ -0,0 +1,9 @@
#!/bin/sh
set -e
IMAGE_NAME=mender-convert
MENDER_CLIENT_VERSION="1.6.0"
docker build . -t ${IMAGE_NAME} --build-arg mender_client_version=${MENDER_CLIENT_VERSION}

11
docker-entrypoint.sh

@ -0,0 +1,11 @@
#!/bin/sh
set -e
# run conversion, args provided to container (end of docker run ...)
cd /mender-convert
echo "Running mender-convert "$@""
./mender-convert "$@"

13
docker-mender-convert

@ -0,0 +1,13 @@
#!/bin/sh
set -e
IMAGE_NAME=mender-convert
MENDER_CONVERT_DIR="$(pwd)"
mkdir -p output
docker run \
--mount type=bind,source=$MENDER_CONVERT_DIR,target=/mender-convert \
--privileged=true \
$IMAGE_NAME "$@"

74
docker/README.md

@ -1,74 +0,0 @@
Docker environment for mender-convert
=====================================
In order to correctly set up partitions and bootloaders, mender-convert has many dependencies,
and their version and name vary between Linux distributions.
To make using mender-convert easier, a reference setup using a Ubuntu 18.04 Docker container
is provided.
You need to [install Docker Engine](https://docs.docker.com/install) to use this environment.
## Build the mender-convert container image
To build a container based on Ubuntu 18.04 with all required dependencies for mender-convert,
copy this directory to your workstation and change the current directory to it.
Then run
```bash
./docker-build
```
This will create a container image you can use to run mender-convert.
## Use the mender-convert container image
Create a directory `input` under the directory where you copied these files (`docker-build`, `docker-mender-convert`, etc.):
```bash
mkdir input
```
Then put your raw disk image into `input`, e.g.
```bash
mv ~/Downloads/2018-11-13-raspbian-stretch.img input/2018-11-13-raspbian-stretch.img
```
You can run mender-convert from inside the container with your desired options, e.g.
```bash
DEVICE_TYPE="raspberrypi3"
RAW_DISK_IMAGE="input/2018-11-13-raspbian-stretch.img"
ARTIFACT_NAME="2018-11-13-raspbian-stretch"
MENDER_DISK_IMAGE="2018-11-13-raspbian-stretch.sdimg"
TENANT_TOKEN="<INSERT-TOKEN-FROM Hosted Mender>"
./docker-mender-convert from-raw-disk-image \
--raw-disk-image $RAW_DISK_IMAGE \
--mender-disk-image $MENDER_DISK_IMAGE \
--device-type $DEVICE_TYPE \
--mender-client /mender \
--artifact-name $ARTIFACT_NAME \
--bootloader-toolchain arm-linux-gnueabihf \
--server-url "https://hosted.mender.io" \
--tenant-token $TENANT_TOKEN
```
Note that the default Mender client is the latest stable and cross-compiled for generic ARM boards,
which should work well in most cases. If you would like to use a different Mender client,
place it in `inputs` and adjust the `--mender-client` argument.
Conversion will take 10-15 minutes, depending on your storage and resources available.
You can watch `output/build.log` for progress and diagnostics information.
After it finishes, you can find your images in the `output` directory on your host machine!
## Known issues
* BeagleBone images might not convert properly using this docker envirnoment due to permission issues: `mount: /mender-convert/output/embedded/rootfs: WARNING: device write-protected, mounted read-only.`

7
docker/docker-build

@ -1,7 +0,0 @@
#!/bin/sh
set -e
IMAGE_NAME=mender-convert
docker build . -t $IMAGE_NAME

33
docker/docker-entrypoint.sh

@ -1,33 +0,0 @@
#!/bin/sh
set -e
MENDER_CLIENT_VERSION="1.6.0" # TODO: Default, support input as env variable
echo "Cross-compiling Mender client $MENDER_CLIENT_VERSION"
# NOTE: we are assuming generic ARM board here, needs to be extended later
export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go
export PATH=$PATH:/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin
go get github.com/mendersoftware/mender
cd $GOPATH/src/github.com/mendersoftware/mender
git checkout $MENDER_CLIENT_VERSION
env CGO_ENABLED=1 \
CC=arm-linux-gnueabihf-gcc \
GOOS=linux \
GOARCH=arm make build
cp $GOPATH/src/github.com/mendersoftware/mender/mender /
# run conversion, args provided to container (end of docker run ...)
cd /mender-convert
echo "Running mender-convert "$@""
./mender-convert "$@"

16
docker/docker-mender-convert

@ -1,16 +0,0 @@
#!/bin/sh
set -e
IMAGE_NAME=mender-convert
INPUT_DIR="$(pwd)/input"
OUTPUT_DIR="$(pwd)/output"
mkdir -p $OUTPUT_DIR
docker run \
--mount type=bind,source=$INPUT_DIR,target=/mender-convert/input,readonly \
--mount type=bind,source=$OUTPUT_DIR,target=/mender-convert/output \
--privileged=true \
$IMAGE_NAME "$@"
Loading…
Cancel
Save