forked from NebraLtd/hm-diag
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
100 lines (77 loc) · 3.05 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
# Docker Container that runs the Nebra Diagnostics Tool
ARG BUILD_BOARD
####################################################################################################
################################## Stage: builder ##################################################
FROM balenalib/"$BUILD_BOARD"-debian-python:bullseye-build-20230530 AS builder
ENV PYTHON_DEPENDENCIES_DIR=/opt/python-dependencies
RUN mkdir /tmp/build
WORKDIR /tmp/build
COPY quectel/ ./quectel
COPY hw_diag/ ./hw_diag
COPY bigquery/ ./bigquery
COPY pyproject.toml ./pyproject.toml
COPY poetry.lock ./poetry.lock
COPY MANIFEST.in ./MANIFEST.in
COPY README.md ./README.md
# hadolint ignore=DL3013
RUN install_packages \
build-essential \
cmake \
gcc \
libtool \
python3-dev \
dbus \
libdbus-glib-1-dev \
libdbus-1-dev && \
python -m venv "$PYTHON_DEPENDENCIES_DIR" && . "$PYTHON_DEPENDENCIES_DIR/bin/activate" && \
pip install --no-cache-dir poetry==1.5.1 && \
poetry config installer.max-workers 10 && \
poetry install --no-cache --no-root && \
poetry build && \
pip install --no-cache-dir dist/hw_diag-1.0.tar.gz && \
tar -xf ./quectel/qfirehose/QFirehose_Linux_Android_V1.4.9.tar.xz
# firehose build, the tar is obtained from quectel and cleaned from build artifacts,
# recompressed by us.
# docker linter wants WORKDIR for changing directory
WORKDIR /tmp/build/QFirehose_Linux_Android_V1.4.9
RUN make
# No need to cleanup the builder
####################################################################################################
################################### Stage: runner ##################################################
FROM balenalib/"$BUILD_BOARD"-debian-python:bullseye-run-20230530 AS runner
ENV PYTHON_DEPENDENCIES_DIR=/opt/python-dependencies
RUN \
install_packages \
wget \
i2c-tools \
libdbus-1-3 \
gpg \
libatomic1
# Nebra uses /opt by convention
WORKDIR /opt/
# Import gpg key
COPY keys/manufacturing-key.gpg ./
# Copy packages from builder
COPY --from=builder "$PYTHON_DEPENDENCIES_DIR" "$PYTHON_DEPENDENCIES_DIR"
# copy modem flashing tool
COPY --from=builder /tmp/build/QFirehose_Linux_Android_V1.4.9/QFirehose /usr/sbin/QFirehose
# copy db migration files
COPY migrations/ /opt/migrations/migrations
COPY alembic.ini /opt/migrations/alembic.ini
# copy start admin session script
COPY start_admin_session /usr/sbin/start_admin_session
# Getting RUN layers together
RUN gpg --import manufacturing-key.gpg && \
rm manufacturing-key.gpg && \
chmod 700 /usr/sbin/start_admin_session && \
mkdir -p /opt/nebra
# Copy ThingsIX Config
COPY thingsix_config.yaml /opt/thingsix/thingsix_config.yaml
# Add python dependencies to PYTHONPATH
ENV PYTHONPATH="${PYTHON_DEPENDENCIES_DIR}:${PYTHONPATH}"
ENV PATH="${PYTHON_DEPENDENCIES_DIR}/bin:${PATH}"
# Copy environment variables startup script
COPY setenv.sh /opt/nebra/setenv.sh
# Copy container startup script
COPY start_diagnostics.sh /opt/start_diagnostics.sh
ENTRYPOINT ["/opt/start_diagnostics.sh"]