-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
144 lines (110 loc) · 5.33 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
##############################################################
# FROM must be the first command in a dockerfile
# Specify Ubuntu digest to pull from
##############################################################
FROM ubuntu:22.04
##############################################################
# Use DEBIAN_FRONTEND=noninteractive to avoid image build
# hang waiting for a default confirmation [Y/n] at some configurations.
##############################################################
ENV DEBIAN_FRONTEND="noninteractive" TZ="US/Pacific"
##############################################################
# Install dependencies
##############################################################
RUN apt-get update && apt upgrade -y
RUN ln -fs /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
RUN DEBIAN_FRONTEND=noninteractive apt install -y tzdata
##############################################################
# Bitbake and Petalinux Dependencies
##############################################################
RUN DEBIAN_FRONTEND=noninteractive apt install -y --fix-missing \
software-properties-common openssh-client gawk wget git diffstat unzip \
texinfo file tar gcc-multilib build-essential chrpath git-lfs socat cpio \
python3 python3-pip python3-pexpect expect xz-utils debianutils \
iputils-ping python3-jinja2 libegl1-mesa libsdl1.2-dev \
xterm rsync curl locales apt-utils sudo vim bash-completion screen \
python3-subunit mesa-common-dev zstd liblz4-tool zstd net-tools \
ca-certificates less nano bc jq bison qemu-system-arm tree libtinfo5 \
autoconf libncurses5-dev libncursesw5-dev zlib1g-dev tftpd tftp-hpa \
libtool rlwrap
RUN dpkg --add-architecture i386 && apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y -q \
zlib1g:i386 libc6-dev:i386 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN DEBIAN_FRONTEND=noninteractive add-apt-repository universe && \
apt-get update && apt install -y libtinfo5
###############################################################
# Map Host user to container
##############################################################
ARG DOCKER_USER=petalinux
ARG U_ID=1000
ARG G_ID=1000
RUN groupadd -g ${G_ID} host-users 2> /dev/null && \
useradd ${DOCKER_USER} -u ${U_ID} -g ${G_ID} -s /bin/bash && \
echo "${DOCKER_USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
##############################################################
# Install additional utilities not available through apt
##############################################################
# https://docs.yoctoproject.org/4.0.11/ref-manual/system-requirements.html?highlight=pylint#ubuntu-and-debian
RUN pip3 install GitPython pylint
# Install the google repo utility
RUN curl -o /usr/local/bin/repo https://storage.googleapis.com/git-repo-downloads/repo
RUN chmod a+x /usr/local/bin/repo
# By default, Ubuntu uses dash as an alias for sh. Dash does not support the source command
# needed for setting up Yocto build environments. Use bash as an alias for sh.
RUN which dash &> /dev/null && (\
echo "dash dash/sh boolean false" | debconf-set-selections && \
DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash) || \
echo "Skipping dash reconfigure (not applicable)"
# Generate locales
RUN locale-gen en_US.UTF-8
# Define the locale we will use
ENV LANG en_US.UTF-8
# Enable improved syntax highlighting for nano (including .bb bitbake files)
RUN cd /usr/share/nano \
&& wget https://raw.githubusercontent.com/scopatz/nanorc/master/install.sh -O- | sh \
&& git clone https://github.com/saizen408/bitbake_nanorc.git /tmp/bitbake_nanorc \
&& cp /tmp/bitbake_nanorc/bb.nanorc /usr/share/nano/
ENV MICRO_CONFIG_HOME="/etc/micro"
# Install micro text editor and move the bb.yaml file into the micro config folder
RUN cd /usr/bin \
&& curl https://getmic.ro | bash \
&& mkdir -p ${MICRO_CONFIG_HOME}/syntax \
&& cp /tmp/bitbake_nanorc/bb.yaml ${MICRO_CONFIG_HOME}/syntax
##############################################################
# Install Petalinux
# Source: https://github.com/carlesfernandez/docker-petalinux
##############################################################
# the HTTP server to retrieve the files from.
ARG HTTP_SERV=http://172.17.0.1:8000/installers
ARG PETA_RUN_FILE=petalinux-v2023.1-05012318-installer.run
COPY accept-eula.sh /
# Run the Petalinux installer
RUN cd / && wget -q ${HTTP_SERV}/${PETA_RUN_FILE} && \
chmod a+rx /${PETA_RUN_FILE} && \
chmod a+rx /accept-eula.sh && \
mkdir -p /opt/Xilinx && \
chmod 777 /tmp /opt/Xilinx && \
cd /tmp && \
sudo -u ${DOCKER_USER} -i /accept-eula.sh /${PETA_RUN_FILE} /opt/Xilinx/petalinux && \
rm -f /${PETA_RUN_FILE} /accept-eula.sh
# Source petalinux upon each login of the container
RUN echo ". /opt/Xilinx/petalinux/settings.sh" >> /etc/profile && \
echo "/usr/sbin/in.tftpd --foreground --listen --address [::]:69 --secure /tftpboot" >> /etc/profile && \
echo ". /etc/profile" >> /root/.profile
# Modify xsdb script
RUN sed -i 's|"$RDI_BINROOT"/unwrapped/"$RDI_PLATFORM$RDI_OPT_EXT"/rlwrap|rlwrap|g' /opt/Xilinx/petalinux/tools/xsct/bin/xsdb
# Set up user environment
ENV TERM=xterm-256color
# Add tftp support
EXPOSE 69/udp
# Create tftpboot dir
RUN mkdir -p /tftpboot && \
chmod 755 /tftpboot
# Switch to work directory
RUN mkdir -p /yocto && \
chmod 755 /yocto
WORKDIR /yocto
USER ${DOCKER_USER}
ENTRYPOINT ["/bin/bash", "-l"]