-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
50 lines (36 loc) · 1.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
FROM alpine:3.21.2 as base
FROM base AS builder
ARG TARGETPLATFORM
COPY . /app
RUN COLOUR='\e[1;93m' && \
echo -e "${COLOUR}Installing build dependencies...\e[0m" && \
if [ "$TARGETPLATFORM" = "linux/arm/v6" ] || [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then BUILD_DEPS="cargo rust"; fi && \
apk --no-cache add --virtual=build-dependencies \
${BUILD_DEPS} \
py3-pip && \
echo -e "${COLOUR}Done.\e[0m"
# Define the python virtual environment
ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv --upgrade-deps $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN COLOUR='\e[1;93m' && \
echo -e "${COLOUR}Installing LabKraken...\e[0m" && \
pip install -r /app/requirements.txt && \
echo -e "${COLOUR}Done.\e[0m"
FROM base AS runner
LABEL maintainer="Patrick Baus <[email protected]>"
LABEL description="Kraken sensor data aggregator."
ARG WORKER_USER_ID=5556
# Upgrade installed packages,
# add a user called `worker`
# Then install Python dependency
RUN apk --no-cache upgrade && \
addgroup -g ${WORKER_USER_ID} worker && \
adduser -D -u ${WORKER_USER_ID} -G worker worker && \
apk --no-cache add python3
COPY --from=builder /opt/venv /opt/venv
# Enable venv
ENV PATH="/opt/venv/bin:$PATH"
COPY --from=builder --chown=worker:worker /app /app
USER worker
CMD ["python3", "-OO", "-u", "/app/kraken_ethernet.py"]