-
Notifications
You must be signed in to change notification settings - Fork 85
/
Dockerfile.fixinventorybase
155 lines (142 loc) · 5.69 KB
/
Dockerfile.fixinventorybase
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
145
146
147
148
149
150
151
152
153
154
155
# This is the Fix Inventory base container. It includes CPython and is used
# as the common base for all the other containers.
FROM fedora:40 AS build-env
ENV LANG="C.UTF-8"
ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TESTS
ARG SOURCE_COMMIT
ARG ARANGO_VERSION=3.11.8
ARG AWS_CLI_VERSION=master
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
RUN echo "I am running on ${BUILDPLATFORM}, building for ${TARGETPLATFORM}"
WORKDIR /
RUN dnf -y update \
&& dnf -y groupinstall "Development Tools" "Development Libraries" \
&& dnf -y install \
gcc \
python3-devel \
python3-pip \
shellcheck \
curl \
ca-certificates \
dateutils \
openssl \
openssl-devel \
rustc \
cargo \
git
# Create CPython venv
WORKDIR /usr/local
RUN python3 -m venv fix-venv-python3
# Download and install Python test tools
RUN . /usr/local/fix-venv-python3/bin/activate && python -m pip install -U pip wheel tox flake8
# Prepare whl build env
RUN mkdir -p /build /build-python
# Build Fix Inventory
COPY requirements-extra.txt /usr/src/requirements-extra.txt
COPY fixlib /usr/src/fixlib
COPY fixcore /usr/src/fixcore
COPY fixworker /usr/src/fixworker
COPY fixmetrics /usr/src/fixmetrics
COPY fixshell /usr/src/fixshell
COPY plugins /usr/src/plugins
WORKDIR /usr/src/fixcore
RUN python3 -m venv /build/jupyterlite-venv-python3
RUN . /build/jupyterlite-venv-python3/bin/activate && python -m pip install -r requirements-jupyterlite.txt
RUN . /build/jupyterlite-venv-python3/bin/activate && python -m jupyter lite build --config jupyter_lite_config.json
# Install Fix Inventory
WORKDIR /usr/src
RUN . /usr/local/fix-venv-python3/bin/activate && pip install -r requirements-extra.txt
RUN . /usr/local/fix-venv-python3/bin/activate && find plugins/ -maxdepth 1 -mindepth 1 -type d -print0 | xargs -0 python -m pip install ./fixlib ./fixcore ./fixworker ./fixmetrics ./fixshell
RUN . /usr/local/fix-venv-python3/bin/activate && python -m pip install fixinventory-plugin-vsphere
RUN . /usr/local/fix-venv-python3/bin/activate && python -m pip install fixinventory-plugin-onprem
# Install AWS CLI
WORKDIR /usr/src
RUN . /usr/local/fix-venv-python3/bin/activate \
&& pip install "git+https://github.com/aws/aws-cli.git@${AWS_CLI_VERSION}"
# Download and install ArangoDB tools
WORKDIR /tmp/arangodb
RUN if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \
ARANGO_URL="https://download.arangodb.com/arangodb311/Community/Linux/arangodb3-client-linux-${ARANGO_VERSION}_x86_64.tar.gz"; \
elif [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \
ARANGO_URL="https://download.arangodb.com/arangodb311/Community/Linux/arangodb3-client-linux-${ARANGO_VERSION}_arm64.tar.gz"; \
else \
echo "Building for unknown platform - not copying ArangoDB client binaries" && exit 0; \
fi && \
curl -L -o arangodb3-client.tar.gz "${ARANGO_URL}" && \
tar -xzf arangodb3-client.tar.gz --strip-components=1 && \
cp usr/bin/arangodump /usr/local/bin/arangodump && \
cp usr/bin/arangorestore /usr/local/bin/arangorestore
# Copy image config and startup files
WORKDIR /usr/src/fixinventory
COPY dockerV2/defaults /usr/local/etc/fixinventory/defaults
COPY dockerV2/common /usr/local/etc/fixinventory/common
COPY dockerV2/bootstrap /usr/local/sbin/bootstrap
COPY dockerV2/postflight /usr/local/sbin/postflight
COPY dockerV2/fixsh-shim /usr/local/bin/fixsh-shim
COPY dockerV2/fixsh-wait /usr/local/bin/fixsh-wait
COPY dockerV2/fixcore-shim /usr/local/bin/fixcore-shim
COPY dockerV2/fixworker-shim /usr/local/bin/fixworker-shim
COPY dockerV2/fixmetrics-shim /usr/local/bin/fixmetrics-shim
RUN chmod 755 \
/usr/local/sbin/bootstrap \
/usr/local/sbin/postflight \
/usr/local/bin/fixsh-shim \
/usr/local/bin/fixcore-shim \
/usr/local/bin/fixworker-shim \
/usr/local/bin/fixmetrics-shim
RUN if [ "${TESTS:-false}" = true ]; then \
shellcheck -a -x -s bash -e SC2034 \
/usr/local/sbin/bootstrap \
; \
fi
COPY dockerV2/dnsmasq.conf /usr/local/etc/dnsmasq.conf
RUN echo "${SOURCE_COMMIT:-unknown}" > /usr/local/etc/git-commit.HEAD
# Setup main image
FROM fedora:40
ENV LANG="C.UTF-8"
ENV TERM="xterm-256color"
ENV COLORTERM="truecolor"
ENV EDITOR="vim"
ENV FIXSHELL_DOWNLOAD_DIRECTORY="/home/fixinventory/downloads"
COPY --from=build-env /usr/local /usr/local
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
WORKDIR /
RUN groupadd -g "${PGID:-0}" -o fixinventory \
&& useradd -g "${PGID:-0}" -u "${PUID:-0}" -o --create-home fixinventory \
&& dnf -y update \
&& dnf -y install \
dumb-init \
python3 \
python3-pip \
iproute \
dnsmasq \
libffi \
openssl \
procps \
dateutils \
curl \
jq \
ca-certificates \
openssh \
unzip \
nano \
vim \
joe \
&& mkdir -p /var/run/fixinventory /home/fixinventory/downloads \
&& /usr/local/sbin/postflight \
&& rm -f /etc/dnsmasq.conf \
&& ln -s /usr/local/etc/dnsmasq.conf /etc/dnsmasq.conf \
&& ln -s /usr/local/bin/fixsh-shim /usr/bin/fixsh \
&& ln -s /usr/local/bin/fixcore-shim /usr/bin/fixcore \
&& ln -s /usr/local/bin/fixworker-shim /usr/bin/fixworker \
&& ln -s /usr/local/bin/fixmetrics-shim /usr/bin/fixmetrics \
&& ln -s /usr/local/bin/fixsh-shim /usr/bin/resh \
&& ln -s /usr/local/bin/fixcore-shim /usr/bin/resotocore \
&& ln -s /usr/local/bin/fixworker-shim /usr/bin/resotoworker \
&& ln -s /usr/local/bin/fixmetrics-shim /usr/bin/resotometrics \
&& dnf clean all \
&& rm -rf /var/cache/dnf /tmp/* /var/tmp/*
ENTRYPOINT ["/bin/dumb-init", "--", "/usr/local/sbin/bootstrap"]
CMD ["/bin/bash"]