S32G docker镜像构建

本文基于S32G GoldVIP1.5分享构建docker镜像时的一些问题和解决方法。
PC环境:ubuntu 20.04
官网上自行下载 GoldVIP-S32G2-1.5.0-binaries.zip

docker安装

按教程https://docs.docker.com或网上教程进行

脚本修改

更换apt源

在docker/config目录下创建source.list

$ pwd
/home/ae/work/gvip1.5/docker/config
$ touch sources.list 

编辑source.list为如下内容:

$ nano sources.list
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted
# deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted
# deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://mirrors.ustc.edu.cn/ubuntu/ bionic universe
# deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic universe
deb http://mirrors.ustc.edu.cn/ubuntu/ bionic-updates universe
# deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://mirrors.ustc.edu.cn/ubuntu/ bionic multiverse
# deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ bionic-updates multiverse
# deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu bionic partner
# deb-src http://archive.canonical.com/ubuntu bionic partner

deb http://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted
# deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted
deb http://mirrors.ustc.edu.cn/ubuntu/ bionic-security universe
# deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic-security universe
deb http://mirrors.ustc.edu.cn/ubuntu/ bionic-security multiverse
# deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic-security multiverse

更换pip源

在docker/config目录下创建pip.conf

$ pwd
/home/ae/work/gvip1.5/docker/config
$ touch pip.conf

编辑pip.conf为如下内容:
[global]
timeout = 6000
index-url = https://mirrors.aliyun.com/pypi/simple/
trusted-host = mirrors.aliyun.com

修改/recipe/goldvip-light.Dockerfile


##
# Copyright 2020-2021 NXP
##

FROM ubuntu:18.04

USER root

ARG USER=vip
ARG DEBIAN_FRONTEND=noninteractive
ARG MINICOM_CONFIG_FILE="/home/$USER/.minirc.dfl"

ENV USER=${USER}
ENV MINICOM_CONFIG_FILE=${MINICOM_CONFIG_FILE}
ENV TERM=linux
ENV HOST_OS=linux

RUN useradd -d /home/$USER -m -s /bin/bash $USER
COPY config/.minirc.dfl ${MINICOM_CONFIG_FILE}
COPY config/prepare_setup.sh /home/$USER
COPY config/device_utils.exp /home/$USER

# WORKDIR is always created as owned by root
WORKDIR /home/$USER/goldvip

ADD config/sources.list /etc/apt/

RUN apt-get update && apt-get install -y                                \
    apt-utils                                                           \
    python3                                                             \
    python3-pip                                                         \
    iproute2 net-tools                                                  \
    iputils-ping                                                        \
    minicom                                                             \
    expect                                                              \
    netbase                                                             \
    openssh-server                                                      \
    vim                                                                 \
    curl                                                                \
    apache2                                                             \
    socat                                                               \
    sudo                                                                \
    tcpreplay                                                           \
    iptables                                                            \
    module-init-tools                                                   \
    strongswan                                                          \
    strongswan-pki                                                      \
    libcharon-extra-plugins                                             \
    iperf3                                                              \
    libiperf0                                                           \
    libsctp1                                                            \
    nodejs                                                              \
    npm

COPY requirements.txt ./

RUN mkdir ~/.pip
ADD config/pip.conf ~/.pip
RUN pip3 install --upgrade pip
RUN pip3 install --no-cache-dir -r requirements.txt




RUN echo "$USER ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers &&            \
    chown -R $USER:$USER /home/$USER &&                                \
    # allow user to access serial devices
    usermod -a -G dialout $USER

COPY scripts/can_to_eth_slow_path_m7.py                                 \
     scripts/can-to-eth-slow-path-m7-host.sh                            \
     scripts/eth-common.sh                                              \
     scripts/eth-common-host.sh                                         \
     scripts/eth-sja-fast-path-host.sh                                  \
     scripts/eth-slow-path-host.sh                                      \
     scripts/eth-pfe-fast-path-host.sh                                  \
     scripts/eth-idps-slow-path-host.sh                                 \
     scripts/eth-ipsec-slow-path-host.sh                                \
     scripts/eth-slow-path-m7-host.sh                                   \
     scripts/eth_slow_path_m7.py                                        \
     idps/someip_packets.pcapng                                         \
     ./

ADD scripts/ml-data-feeder ml-data-feeder/.

RUN chmod +x *host.sh /home/$USER/prepare_setup.sh &&                        \
    # bind a pseudo terminal to a tcp socket - custom setup to access serial on Windows
    echo "source /home/$USER/prepare_setup.sh" >> /home/$USER/.bashrc &&     \
    # change mode for running all UI apps without sudo permission
    echo "sudo chmod 666 /home/vip/.Xauthority" >> /home/$USER/.bashrc

# Append include directives to ipsec.conf and ipsec.secrets conf files.
RUN echo "\ninclude /etc/ipsec.*.secrets\n" >> /etc/ipsec.secrets && \
    echo "\ninclude /etc/ipsec.d/*.conf\n" >> /etc/ipsec.conf

# Set the default encoding to UTF-8
ENV LANG C.UTF-8

# Copy application to docker
ADD ui /var/www/html

# Give execution right for scripts on UI application
RUN chmod +x /var/www/html/*.sh
RUN chmod a+x /home/$USER/device_utils.exp

# Copy front-end scripts to home folder
RUN mv /var/www/html/*.sh /home/$USER/goldvip

# Install GUI dependencies
RUN cd /var/www/html/nxpservices && npm install

USER ${USER}
ENTRYPOINT ["bash"]

在这里插入图片描述

镜像制作

$ cd <GoldVIP_install_directory>/docker
$ sudo chmod +x create_image.sh
$ ./create_image.sh
```

## 运行镜像

```
$ sudo docker run -it --rm --name goldvip --network=host --privileged \
	-v /home/ae/.Xauthority:/home/vip/.Xauthority \
	-v /lib/modules:/lib/modules:ro \
	-e DISPLAY=$DISPLAY \
	-e XAUTHORITY=/home/vip/.Xauthority	\
	docker-goldvip:1.5.0
```

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值