-
Notifications
You must be signed in to change notification settings - Fork 52
/
build-rootfs-size-docker.sh
executable file
·81 lines (66 loc) · 3.03 KB
/
build-rootfs-size-docker.sh
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
#!/bin/bash -xe
#
# Build the required docker image to run rootfs_size.py
#
# Script Variables:
# DOCKER_IMG_NAME: <optional, the name of the docker image to generate>
# default is openbmc/ubuntu-rootfs-size
# DISTRO: <optional, the distro to build a docker image against>
# UBUNTU_MIRROR: [optional] The URL of a mirror of Ubuntu to override the
# default ones in /etc/apt/sources.list
# default is empty, and no mirror is used.
# DOCKER_REG: <optional, the URL of a docker registry to utilize
# instead of our default (public.ecr.aws/ubuntu)
# (ex. docker.io)
# http_proxy: The HTTP address of the proxy server to connect to.
# Default: "", proxy is not setup if this is not set
http_proxy=${http_proxy:-}
UBUNTU_MIRROR=${UBUNTU_MIRROR:-""}
set -uo pipefail
DOCKER_IMG_NAME=${DOCKER_IMG_NAME:-"openbmc/ubuntu-rootfs-size"}
DISTRO=${DISTRO:-"ubuntu:bionic"}
docker_reg=${DOCKER_REG:-"public.ecr.aws/ubuntu"}
PROXY=""
MIRROR=""
if [[ -n "${UBUNTU_MIRROR}" ]]; then
MIRROR="RUN echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME) main restricted universe multiverse\" > /etc/apt/sources.list && \
echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-updates main restricted universe multiverse\" >> /etc/apt/sources.list && \
echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-security main restricted universe multiverse\" >> /etc/apt/sources.list && \
echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-proposed main restricted universe multiverse\" >> /etc/apt/sources.list && \
echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-backports main restricted universe multiverse\" >> /etc/apt/sources.list"
fi
################################# docker img # #################################
if [[ "${DISTRO}" == "ubuntu"* ]]; then
if [[ -n "${http_proxy}" ]]; then
PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy"
fi
Dockerfile=$(cat << EOF
FROM ${docker_reg}/${DISTRO}
${PROXY}
${MIRROR}
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -yy \
python3 \
python3-dev\
python3-yaml \
python3-mako \
python3-pip \
python3-setuptools \
curl \
git \
wget \
sudo \
squashfs-tools
# Final configuration for the workspace
RUN grep -q ${GROUPS[0]} /etc/group || groupadd -g ${GROUPS[0]} ${USER}
RUN mkdir -p $(dirname "${HOME}")
RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS[0]} ${USER}
RUN sed -i '1iDefaults umask=000' /etc/sudoers
RUN echo "${USER} ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers
RUN /bin/bash
EOF
)
fi
################################# docker img # #################################
# Build above image
docker build --network=host -t "${DOCKER_IMG_NAME}" - <<< "${Dockerfile}"