2021-11-27 15:21:05 +01:00
|
|
|
FROM alpine:latest as download
|
|
|
|
RUN apk --no-cache add curl && mkdir /downloads
|
|
|
|
# Download installation files
|
2022-05-10 17:52:23 +02:00
|
|
|
RUN curl https://github.com/avollkopf/craftbeerpi4-ui/archive/main.zip -L -o ./downloads/cbpi-ui.zip
|
2018-11-04 00:47:26 +01:00
|
|
|
|
2022-02-14 09:54:27 +01:00
|
|
|
FROM python:3.9 as base
|
2018-11-04 00:47:26 +01:00
|
|
|
|
2021-11-27 15:21:05 +01:00
|
|
|
# Install dependencies
|
|
|
|
RUN apt-get update \
|
|
|
|
&& apt-get upgrade -y
|
|
|
|
RUN apt-get install --no-install-recommends -y \
|
|
|
|
libatlas-base-dev \
|
|
|
|
libffi-dev \
|
|
|
|
python3-pip \
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
2018-11-04 00:47:26 +01:00
|
|
|
|
2021-12-02 22:21:16 +01:00
|
|
|
ENV VIRTUAL_ENV=/opt/venv
|
2018-11-04 00:47:26 +01:00
|
|
|
|
2021-11-27 15:21:05 +01:00
|
|
|
# Create non-root user working directory
|
|
|
|
RUN groupadd -g 1000 -r craftbeerpi \
|
|
|
|
&& useradd -u 1000 -r -s /bin/false -g craftbeerpi craftbeerpi \
|
2021-12-02 22:21:16 +01:00
|
|
|
&& mkdir /cbpi \
|
|
|
|
&& chown craftbeerpi:craftbeerpi /cbpi \
|
|
|
|
&& mkdir -p $VIRTUAL_ENV \
|
|
|
|
&& chown -R craftbeerpi:craftbeerpi ${VIRTUAL_ENV}
|
|
|
|
|
|
|
|
USER craftbeerpi
|
|
|
|
|
|
|
|
# create virtual environment
|
|
|
|
RUN python3 -m venv $VIRTUAL_ENV
|
|
|
|
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
|
|
|
|
|
|
|
RUN python3 -m pip install --no-cache-dir --upgrade pip setuptools wheel
|
2018-11-04 00:47:26 +01:00
|
|
|
|
2021-12-03 00:35:45 +01:00
|
|
|
# Install craftbeerpi requirements for better caching
|
|
|
|
COPY --chown=craftbeerpi ./requirements.txt /cbpi-src/
|
|
|
|
RUN pip3 install --no-cache-dir -r /cbpi-src/requirements.txt
|
|
|
|
|
2021-12-07 21:09:50 +01:00
|
|
|
# Install RPi.GPIO separately because it's excluded in setup.py for non-raspberrys.
|
|
|
|
# This can enable GPIO support for the image when used on a raspberry pi and the
|
|
|
|
# /dev/gpiomem device.
|
2022-02-14 07:53:04 +01:00
|
|
|
RUN pip3 install --no-cache-dir RPi.GPIO==0.7.1
|
2021-12-07 21:09:50 +01:00
|
|
|
|
2021-12-04 12:09:46 +01:00
|
|
|
FROM base as deploy
|
2021-11-27 15:21:05 +01:00
|
|
|
# Install craftbeerpi from source
|
2021-12-02 22:21:16 +01:00
|
|
|
COPY --chown=craftbeerpi . /cbpi-src
|
2021-11-27 15:21:05 +01:00
|
|
|
RUN pip3 install --no-cache-dir /cbpi-src
|
2018-11-04 00:47:26 +01:00
|
|
|
|
2021-11-27 15:21:05 +01:00
|
|
|
# Install craftbeerpi-ui
|
2021-12-02 22:21:16 +01:00
|
|
|
COPY --from=download --chown=craftbeerpi /downloads /downloads
|
2021-11-27 15:21:05 +01:00
|
|
|
RUN pip3 install --no-cache-dir /downloads/cbpi-ui.zip
|
2018-11-04 00:47:26 +01:00
|
|
|
|
2021-11-27 15:21:05 +01:00
|
|
|
# Clean up installation files
|
2021-12-02 22:21:16 +01:00
|
|
|
USER root
|
2021-11-27 15:21:05 +01:00
|
|
|
RUN rm -rf /downloads /cbpi-src
|
|
|
|
USER craftbeerpi
|
|
|
|
|
2021-12-02 22:21:16 +01:00
|
|
|
WORKDIR /cbpi
|
|
|
|
RUN ["cbpi", "setup"]
|
2021-11-27 15:21:05 +01:00
|
|
|
|
|
|
|
EXPOSE 8000
|
|
|
|
|
|
|
|
# Start cbpi
|
2022-02-14 07:53:04 +01:00
|
|
|
CMD ["cbpi", "start"]
|