mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-25 16:38:36 +01:00
Avoid root when installing cbpi
This commit is contained in:
parent
80bdac45ce
commit
0c380d5912
1 changed files with 27 additions and 16 deletions
43
Dockerfile
43
Dockerfile
|
@ -3,7 +3,7 @@ RUN apk --no-cache add curl && mkdir /downloads
|
||||||
# Download installation files
|
# Download installation files
|
||||||
RUN curl https://github.com/avollkopf/craftbeerpi4-ui/archive/main.zip -L -o ./downloads/cbpi-ui.zip
|
RUN curl https://github.com/avollkopf/craftbeerpi4-ui/archive/main.zip -L -o ./downloads/cbpi-ui.zip
|
||||||
|
|
||||||
FROM python:3.7
|
FROM python:3.9
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
|
@ -14,28 +14,39 @@ RUN apt-get install --no-install-recommends -y \
|
||||||
python3-pip \
|
python3-pip \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
RUN python -m pip install --upgrade pip setuptools wheel
|
ENV VIRTUAL_ENV=/opt/venv
|
||||||
|
|
||||||
WORKDIR /cbpi
|
|
||||||
# Create non-root user working directory
|
# Create non-root user working directory
|
||||||
RUN groupadd -g 1000 -r craftbeerpi \
|
RUN groupadd -g 1000 -r craftbeerpi \
|
||||||
&& useradd -u 1000 -r -s /bin/false -g craftbeerpi craftbeerpi \
|
&& useradd -u 1000 -r -s /bin/false -g craftbeerpi craftbeerpi \
|
||||||
&& chown craftbeerpi:craftbeerpi /cbpi
|
&& mkdir /cbpi \
|
||||||
|
&& chown craftbeerpi:craftbeerpi /cbpi \
|
||||||
# Install craftbeerpi from source
|
&& mkdir -p $VIRTUAL_ENV \
|
||||||
COPY . /cbpi-src
|
&& chown -R craftbeerpi:craftbeerpi ${VIRTUAL_ENV}
|
||||||
RUN pip3 install --no-cache-dir /cbpi-src
|
|
||||||
|
|
||||||
# Install craftbeerpi-ui
|
|
||||||
COPY --from=download /downloads /downloads
|
|
||||||
RUN pip3 install --no-cache-dir /downloads/cbpi-ui.zip
|
|
||||||
|
|
||||||
# Clean up installation files
|
|
||||||
RUN rm -rf /downloads /cbpi-src
|
|
||||||
|
|
||||||
USER craftbeerpi
|
USER craftbeerpi
|
||||||
|
|
||||||
RUN cbpi setup
|
# 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
|
EXPOSE 8000
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue