:::hw
Board|ARTIK530||
:::
:::sw
OS|dockzen-os|v1.8.0
:::
:::sw
App|webview-native-app|https://developer.tizen.org/community/tip-tech/webview-native-application
:::
:::sw
Etc.|(base-container)iot-headed-3parts-armv7l-artik530_710.tar.gz|http://download.tizen.org/releases/previews/iot/preview1/tizen-4.0-unified_20171016.1/images/standard/iot-headed-3parts-armv7l-artik530_710/
:::
1. Overview
To run Container, HostOSHostOS have to support docker.
This project indicates how to make a tizen base container and tizen app container.
2. Story
How to build tizen-base-container and tizen-app-container.
•Prerequsite
• ARTIK530 board
• download : ARTIK530 headed platform image and webview native app
3. How to create
A. How to build tizen-base-container
- create folder of images and tool
- save platform image to "/images" folder
- create file of config "headed-artik.ini"
- create file of build.sh
- Add do-smack to folder of tool
```
$ mkdir images
$ cd images
images $ wget http://download.tizen.org/releases/previews/iot/preview1/tizen-4.0-unified_20171016.1/images/standard/iot-headed-3parts-armv7l-artik530_710/tizen-4.0-unified_20171016.1_iot-headed-3parts-armv7l-artik530_710.tar.gz
images $ cd ..
$ mkdir tool
$ touch headed-artik.ini
$ vi headed-artik.ini
#! /bin/bash
PLATFORM_IMG="tizen-4.0-unified_20171016.1_iot-headed-3parts-armv7l-artik530_710.tar.gz"
BASE_CONTAINER_NAME="52.78.68.250:5000/dockzen/armhf/iot-headed-artik:m2"
$ touch bash.sh
$ vi bash.sh
#! /bin/bash
BUILD_ALL=false
CLEAN_ALL=false
BASE_CONTAINER_NAME="base-container"
#source ./settings.sh
read_config()
{
. $PROJECT_DIR/$target
echo "PLATFORM_IMG="$PLATFORM_IMG
echo "BASE_CONTAINER_NAME="$BASE_CONTAINER_NAME
}
# unmount processing point
unmount_image_all()
{
sudo umount $MOUNT_PATH/opt/usr/
sudo umount $MOUNT_PATH/opt/
sudo umount $MOUNT_PATH/
sync
sleep 1
}
# define directory
init()
{
PROJECT_DIR=$(pwd)
OUTPUT_DIR=$PROJECT_DIR/output
MOUNT_PATH=$PROJECT_DIR/mnt
TOOL_PATH=$PROJECT_DIR/tool
#SKIP_BASE_IMAGE=false
# clean working directory
#if [ "$BUILD_ALL" = true ] || [ "$CLEAN_ALL" = true ]
#then sudo rm -rf $OUTPUT_DIR
#fi
if [ -d "$MOUNT_PATH" ]
then
echo $MOUNT_PATH ": file exist already"
sudo rm -rf $MOUNT_PATH
fi
# create working directory
mkdir -p $MOUNT_PATH
unmount_image_all
}
delete_processing_files()
{
cd $PROJECT_DIR
rm -rf $MOUNT_PATH/../do-smack
sudo rm -rf $MOUNT_PATH
rm *.img
rm $PLATFORM_IMG
}
# prepare working directory
copy_image()
{
echo "IMAGE_NAME $PLATFORM_IMG"
echo "pwd $PROJECT_DIR"
echo "image copy"
#echo "cp ./images/$CONTAINER_BASE_IMG $CONTAINER_BASE_IMG"
cp images/$PLATFORM_IMG $PLATFORM_IMG
tar -xvf $PLATFORM_IMG
}
mount_image()
{
# mount images
if [ -f "rootfs.img" ]
then
echo "mount rootfs.img"
sudo mount rootfs.img $MOUNT_PATH/
fi
if [ -f "system-data.img" ]
then
echo "mount system-data.img"
sudo mount system-data.img $MOUNT_PATH/opt/
fi
if [ -f "user.img" ]
then
echo "mount user.img"
sudo mount user.img $MOUNT_PATH/opt/usr/
fi
}
check_xattr()
{
arch_name=`uname -a | grep arm`
if [ -z $arch_name ]; then
echo "arch : x86"
cp -rf $TOOL_PATH/do-smack/do-smack-64 $PROJECT_DIR/do-smack
else
cp -rf $TOOL_PATH/do-smack/do-smack $PROJECT_DIR/do-smack
echo "arch : arm"
fi
cd $MOUNT_PATH
# execute do-smack
sudo bash -c 'find ./ | while read file; do ../do-smack $file on; done' | egrep "CHECK|TARGET"
rm $MOUNT_PATH/../do-smack
}
create_base_image()
{
cd $MOUNT_PATH
echo tar --xattrs -cf "docker-"$PLATFORM_IMG .
sudo tar --xattrs -cf $OUTPUT_DIR/"docker-"$PLATFORM_IMG .
}
import_base_image()
{
cd $OUTPUT_DIR
echo docker import "docker-"$PLATFORM_IMG $BASE_CONTAINER_NAME
docker import "docker-"$PLATFORM_IMG $BASE_CONTAINER_NAME
unmount_image_all
rm -rf "docker-"$PLATFORM_IMG $BASE_CONTAINER_NAME
}
patch_platform()
{
# change /etc/fstab
echo cp $TOOL_PATH/fstab $MOUNT_PATH/etc/fstab
sudo cp $TOOL_PATH/fstab $MOUNT_PATH/etc/fstab
}
image_push()
{
echo "### docker push"
echo -n "Do you want push to server? y or n (default:n): "
read input
if [ "$input" = "y" ]
then
echo docker push $BASE_CONTAINER_NAME
docker push $BASE_CONTAINER_NAME
fi
}
save_image()
{
echo "### docker save"
echo docker save -o $OUTPUT_DIR/$PLATFORM_IMG $BASE_CONTAINER_NAME
docker save -o $OUTPUT_DIR/$PLATFORM_IMG $BASE_CONTAINER_NAME
}
main()
{
init
read_config
copy_image
mount_image
patch_platform
check_xattr
create_base_image
import_base_image
delete_processing_files
image_push
save_image
}
clean()
{
init
delete_processing_files
}
cli_help()
{
echo "Usage: ./build.sh [options...] xxxx.ini"
echo "ex) ./build.sh headed-artik"
echo "Options: "
echo "-a | --all : create base image all with downloading existing image" >&2 ;
echo "-c | --clean : clean" >&2 ;
echo "-h | --help : help" >&2 ;
}
OPTS=`getopt -o ahc --long all,help,clean -- "$@"`
if [ $? != 0 ] ; then cli_help; exit 1 ; fi
eval set -- "$OPTS"
while true; do
case "$1" in
-a | --all )
BUILD_ALL=true;
shift ;;
-c | --clean )
echo "clean working files & directories"
CLEAN_ALL=true; clean; exit 0;
shift ;;
-h | --help ) cli_help; exit 0; shift ;;
-- ) shift; break ;;
* ) echo "Invalid option": exit 0; break ;;
esac
done
if [ -z $1 ]
then
cli_help;
exit 0;
fi
target=$1
main
```
- build image
```
$ ./build.sh headed-artik.ini
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
52.78.68.250:5000/dockzen/armhf/iot-headed-artik m2 fa9e95793d37 About an hour ago 840MB
```
B. How to build tizen-app-container
- create dockerfile
```c
FROM 52.78.68.250:5000/dockzen/iot-headed-artik:m2
# disable for connman service
RUN rm -rf /usr/lib/systemd/system/net-config.service
RUN rm -rf /usr/lib/systemd/system/connman.socket
RUN rm -rf /usr/lib/systemd/system/connman.service
# gl-ddk plugin
COPY gl-ddk /usr/tmp/
RUN rpm -Uvh /usr/tmp/pkg/*.rpm --force --nodeps
RUN cp /usr/tmp/conf/99-GPU-Acceleration.rules /etc/udev/rules.d/
RUN chsmack -a "_" /etc/udev/rules.d/99-GPU-Acceleration.rules
# copy service
COPY webview.service /usr/lib/systemd/user/webview.service
RUN chsmack -a "_" /usr/lib/systemd/user/webview.service
RUN ln -s /usr/lib/systemd/user/webview.service /usr/lib/systemd/user/default.target.wants/
RUN chsmack -a "_" /usr/lib/systemd/user/default.target.wants/webview.service
COPY display_on.service /usr/lib/systemd/system/display_on.service
RUN chsmack -a "_" /usr/lib/systemd/system/display_on.service
RUN ln -s /usr/lib/systemd/system/display_on.service /usr/lib/systemd/system/multi-user.target.wants/
RUN chsmack -a "_" /usr/lib/systemd/system/multi-user.target.wants/display_on.service
# install tpk
COPY *.tpk /usr/
RUN tpk-backend -i /usr/org.example.webview-1.0.0-arm.tpk
# Remove service of menu-screen
RUN rm -rf /usr/lib/systemd/user/starter.path
RUN rm -rf /usr/lib/systemd/user/default.target.wants/starter.path
RUN rm -rf /usr/lib/systemd/user/starter.service
# make share folder
RUN mkdir /opt/usr/webUI
RUN chown tizenglobalapp:root /opt/usr/webUI
COPY agent_ip.json /opt/usr/webUI
RUN chown tizenglobalapp:root /opt/usr/webUI/agent_ip.json
# Remove
RUN rm -rf /usr/tmp/pkg
RUN rm -rf /usr/tmp/conf
```
- build image
```
$ docker build --privileged -t 52.78.68.250:5000/dockzen/armhf/dockzen-webui .
```
Notice
Are you sure to delete this post?
modenize tizen platform as a container
1
2
|
Last modified on November 28, 2017
Craft info. | |
Maker |
![]() |
Status | Planning |
Period | ~ |
About This Craft | |
tizen container can be worked on Dockzen-OS which has docker-engine on Tizen | |
Making Note