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

Dockerfile.ubuntu1804 updated #3

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
74 changes: 74 additions & 0 deletions docker_setup/Dockerfile.ubuntu1804
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Download base image ubuntu 18.04
FROM ubuntu:18.04

# default group id and user id if not setting in build command
ARG host_uid=1000
ARG host_gid=1000
ARG USERNAME=RZuser

ARG TZ="Etc/UTC"

# use bash instead of dash as default /bin/sh
RUN rm /bin/sh && ln -s /bin/bash /bin/sh

# Update Ubuntu Software repository
# install require packages

RUN DEBIAN_FRONTEND=noninteractive \
&&apt-get update \
&& apt-get install -y --no-install-recommends gawk \
wget git-core diffstat unzip texinfo gcc-multilib \
build-essential chrpath socat cpio python python3 \
python3-pip python3-pexpect xz-utils debianutils \
iputils-ping libsdl1.2-dev xterm p7zip-full \
texlive-base apt-utils locales lsb-release whiptail \
libasound2-dev libcurl4-openssl-dev libdbus-1-dev \
libdbus-glib-1-dev libgconf2-dev libgtk2.0-dev \
libgtk-3-dev libpulse-dev libx11-xcb-dev libxt-dev \
sharutils vim automake bc binfmt-support bison \
ca-certificates ccache cmake curl device-tree-compiler \
devscripts dh-exec dh-make dosfstools dpkg-dev fakeroot \
flex gdisk git kmod libncurses5 libncurses5-dev libssl-dev \
mtools parted pkg-config pv python3-dev python-dev \
sudo swig udev python-ply ninja-build libwayland-dev \
golang tmux

# Install tzdata
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata

# Customize the time zone
RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone \
&& dpkg-reconfigure -f noninteractive tzdata

# Setup the locale
RUN locale-gen en_US.UTF-8 \
&& update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8

ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8
ENV LANGUAGE=en_US:en

ENV USER $USERNAME

RUN groupadd -g $host_gid $USERNAME
RUN adduser --disabled-password --shell /bin/bash \
--uid $host_uid --gid $host_gid \
--gecos '' $USERNAME

RUN adduser $USERNAME sudo

RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

# Set work directory
#RUN mkdir -p /home/$USERNAME/$WORK_DIR

# To have a more colorful world
ENV TERM xterm-256color

USER $USERNAME

RUN echo PS1=\"\\[\\e[33m\\]dir\:\ \\w\\n\\[\\e[1\;31m\\]\\u\@\(docker\)\$\\[\\e[00m\\]\ \" >> ~/.bashrc
RUN echo printf=\"\\e]2\;docker\\a\" >> ~/.bashrc

WORKDIR /home/$USERNAME/
52 changes: 42 additions & 10 deletions docker_setup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,14 @@ xz-utils debianutils iputils-ping libsdl1.2-dev xterm p7zip-full

**Your container is now set up.**

### 3.4 Generate the Ubuntu 16.04 image by using dockerfile
In order to generate the build environment with docker more easier, You can just use Dockerfile.ubuntu1604 file. The default image tag is "rzg", you can also replace to yours.
### 3.4 Generate the Ubuntu 16.04/18.04 image by using dockerfile
In order to generate the build environment with docker more easier, You can just use Dockerfile.ubuntu1604 or Dockerfile.ubuntu1804 file. The default image tag is "rz_world", you can also replace to yours.
```
$ docker build --no-cache --build-arg "host_uid=$(id -u)" --build-arg "host_gid=$(id -g)" --build-arg "USERNAME=$USER" --tag rzg -f ./Dockerfile.ubuntu1604 .
$ cd rzg_stuff/docker_setup
$ docker build --no-cache --build-arg "host_uid=$(id -u)" --build-arg "host_gid=$(id -g)" --build-arg "USERNAME=$USER" --build-arg "TZ=$(cat /etc/timezone)" --tag rz_world -f ./Dockerfile.ubuntu1804 .
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
rzg latest 1234567890ab 5 hours ago 1.18GB
rz_world latest 1234567890ab 5 hours ago 1.18GB
$
```

Expand All @@ -296,19 +297,25 @@ If you really don't like the name that was automatically generated, you can chan
$ docker rename CONTAINER NEW_NAME
```

**4.4 Run the container if you generate the image by the Dockerfile.ubuntu1604 file**
**4.4 Run the container if you generate the image by the Dockerfile.ubuntu1604/Dockerfile.ubuntu1804 file**
Make sure you put everything into your host workdir folder. Here is an example below.
```
[In Host]
$ cd $HOME/workdir
$ ls
build extra meta-gplv2 meta-openembedded meta-rzg2 poky
$ docker run -it --rm -v $PWD:/workdir rzg /bin/bash
user@docker:/workdir $ source poky/oe-init-build-env
user@docker:/workdir/build $ bitbake core-image-minimal
user@docker:/workdir/build $
$ docker run -it --rm -v $PWD:/home/$USER/workdir rz_world /bin/bash
[In Container]
dir: ~/
user@(docker)$ cd /home/$USER/workdir
dir: ~/workdir
user@(docker)$ source poky/oe-init-build-env
dir: ~/workdir
user@(docker)$ bitbake core-image-minimal
dir: ~/workdir
user@(docker)$
```


## 5. extra notes
```
$ docker images # shows you your availible images
Expand Down Expand Up @@ -371,4 +378,29 @@ You can remove your old container now because it's not needed anymore
$ docker rm distracted_bohr
```

## 7. The useful script to have a build environment for RENESAS RZ series
* [Build docker image named "rz_world"]
```
$ cd docker_setup
$ ./build_rz_world.sh
[After done, check if the script create the rz_world image for you]
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
rz_world latest YUOR_IMAGE ID 2 hours ago 1.45GB

```

* [Go into container refer from "rz_world" image tag]
You can run ./go_rz_world.sh with argument
```
$ cd docker_setup
$ ./go_rz_world.sh [/path/to/host/workdir]
[After enterd, the workdir will be mapped : "/path/to/host/workdir" <-> "/path/to/container/workdir"]
```
Or you can run ./go_rz_world.sh without argument
```
$ cd [/your/workdir/in/host]
$ /path/to/go_rz_world.sh
[After enterd, the workdir will be mapped : "/your/workdir/in/host" <-> "/home/renesas/workdir"]
```
Note: If your customize the image tag, please update the ./go_rz_world.sh script, make sure it can find the correct image tag.
12 changes: 12 additions & 0 deletions docker_setup/build_rz_world.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# setup default docker image tag
IMAGE_TAG=rz_world

# if user setup the tag name, just use it
if [ $1 ] ; then
IMAGE_TAG=$1
fi

# start to build the docker image
docker build --no-cache --build-arg "host_uid=$(id -u)" --build-arg "host_gid=$(id -g)" --build-arg "USERNAME=$USER" --build-arg "TZ=$(cat /etc/timezone)" --tag $IMAGE_TAG -f ./Dockerfile.ubuntu1804 .
18 changes: 18 additions & 0 deletions docker_setup/go_rz_world.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

# setup default docker image tag
IMAGE_TAG=rz_world
WORK_DIR_=workdir

# if user give workdir, set it as workdir
if [ $1 ] ; then
WORK_DIR_=$1
if [ ! -d $WORK_DIR_ ]; then
WORK_DIR_=$PWD
fi
# go into RZ world
docker run -it --rm -h "renesas" -v $WORK_DIR_:$WORK_DIR_ -w $WORK_DIR_ $IMAGE_TAG /bin/bash
else
# go into default RZ world
docker run -it --rm -h "renesas" -v $PWD:/home/renesas/$WORK_DIR_ $IMAGE_TAG /bin/bash
fi