craftbeerpi4-pione/Dockerfile
2021-12-02 23:40:46 +01:00

54 lines
No EOL
1.4 KiB
Docker

FROM alpine:latest as download
RUN apk --no-cache add curl && mkdir /downloads
# Download installation files
RUN curl https://github.com/avollkopf/craftbeerpi4-ui/archive/main.zip -L -o ./downloads/cbpi-ui.zip
FROM python:3.9
# 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/*
ENV VIRTUAL_ENV=/opt/venv
# Create non-root user working directory
RUN groupadd -g 1000 -r craftbeerpi \
&& useradd -u 1000 -r -s /bin/false -g craftbeerpi craftbeerpi \
&& 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
# Install craftbeerpi from source
COPY --chown=craftbeerpi . /cbpi-src
RUN pip3 install --no-cache-dir /cbpi-src
# Install craftbeerpi-ui
COPY --from=download --chown=craftbeerpi /downloads /downloads
RUN pip3 install --no-cache-dir /downloads/cbpi-ui.zip
# Clean up installation files
USER root
RUN rm -rf /downloads /cbpi-src
USER craftbeerpi
WORKDIR /cbpi
RUN ["cbpi", "setup"]
EXPOSE 8000
# Start cbpi
CMD ["cbpi", "start"]