multiplatform build
This commit is contained in:
38
Dockerfile
38
Dockerfile
@@ -1,4 +1,7 @@
|
||||
FROM python:3.12-alpine3.20 AS build_bluepy
|
||||
# This is the build stage for getting all python libs. Mainly it's for reducing the final image size because for building and installing the pips, many tools are needed which are just bloat to the final image.
|
||||
FROM python:3.12-alpine3.20 AS pip_build_stage
|
||||
|
||||
COPY ./python/requierements.txt /
|
||||
|
||||
RUN apk add \
|
||||
make \
|
||||
@@ -8,17 +11,32 @@ RUN apk add \
|
||||
build-base \
|
||||
freetype-dev \
|
||||
libpng-dev \
|
||||
openblas-dev
|
||||
openblas-dev \
|
||||
libxml2-dev \
|
||||
libxslt-dev
|
||||
|
||||
# BluePy needs to be build here... idk why but pip install fails on alpine somehow
|
||||
RUN git clone https://github.com/IanHarvey/bluepy.git && \
|
||||
cd bluepy && \
|
||||
python3.12 setup.py build && \
|
||||
python3.12 setup.py install
|
||||
python3.12 setup.py install && \
|
||||
cd /
|
||||
|
||||
# Normal pip install for pyyaml failed on RPI4, so I build it here
|
||||
RUN git clone https://github.com/yaml/pyyaml.git && \
|
||||
cd pyyaml && \
|
||||
python3.12 setup.py build && \
|
||||
python3.12 setup.py install && \
|
||||
cd /
|
||||
|
||||
RUN pip3.12 install -r requierements.txt
|
||||
|
||||
|
||||
# This is the stage for the final image
|
||||
FROM python:3.12-alpine3.20
|
||||
|
||||
WORKDIR /src
|
||||
COPY ./python/src/ .
|
||||
COPY ./python/requierements.txt .
|
||||
COPY ./python/docker_entrypoint.sh /
|
||||
RUN mkdir data
|
||||
RUN touch DOCKER
|
||||
@@ -26,12 +44,10 @@ VOLUME /src/data
|
||||
|
||||
RUN apk add --no-cache sudo bluez tzdata
|
||||
ENV TZ=Europe/Berlin
|
||||
ENV DOCKER=TRUE
|
||||
|
||||
# Copy bluepy from the bluepy build stage
|
||||
COPY --from=build_bluepy /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
|
||||
COPY --from=build_bluepy /usr/local/bin /usr/local/bin
|
||||
# Copy pips from the pip build stage
|
||||
COPY --from=pip_build_stage /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
|
||||
COPY --from=pip_build_stage /usr/local/bin /usr/local/bin
|
||||
|
||||
RUN pip3.12 install -r requierements.txt && rm requierements.txt
|
||||
# RUN echo '@reboot root python3.12 /src/serve_json.py' >> /etc/crontab
|
||||
|
||||
ENTRYPOINT sh /docker_entrypoint.sh
|
||||
ENTRYPOINT sh /docker_entrypoint.sh
|
||||
|
||||
Reference in New Issue
Block a user