From 37f2ecc8d2e1235ccfb732018ed4595b6304dc64 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Fri, 7 Oct 2022 18:16:33 -0400 Subject: [PATCH] fix dockerfile build Fixes #25 --- Dockerfile | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index e464b30..627f2e7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ -# buildstage -FROM python:2.7.18-alpine3.11 as buildstage +# syntax = docker/dockerfile:latest +FROM python:2.7.18-buster AS buildstage # build args ARG BUILD_VERSION @@ -8,26 +8,41 @@ ARG GITHUB_SHA=$COMMIT # note: BUILD_VERSION may be blank, COMMIT is also available # note: build_plist.py uses BUILD_VERSION and GITHUB_SHA -# setup build directory -RUN mkdir /build -WORKDIR /build/ +# create build dir and copy GitHub repo there +# todo - add `--link` once hadolint supports this syntax, see https://github.com/hadolint/hadolint/issues/826 +COPY . /build -# copy repo -COPY . . +# set build dir +WORKDIR /build -RUN python # update pip \ - -m pip --no-python-version-warning --disable-pip-version-check install --upgrade pip==20.3.4 setuptools \ - && python -m pip install --upgrade -r requirements-dev.txt # install dev requirements \ - && python ./scripts/install_requirements.py # install plugin requirements \ - && python ./scripts/build_plist.py # build plist \ - && rm -r ./scripts/ # remove scripts dir +# update packages +RUN apt-get update \ + && apt-get -y --no-install-recommends install \ + # install git -> required for pip to install from git + git=1:2.20.1* \ + && rm -rf /var/lib/apt/lists/* -# single layer deployed image -FROM scratch +# update pip +RUN python -m pip --no-python-version-warning --disable-pip-version-check install --no-cache-dir --upgrade \ + pip==20.3.4 setuptools + # dev requirements not necessary for docker image, significantly speeds up build since lxml doesn't need to build + +# build plugin +RUN python ./scripts/install_requirements.py \ + && python ./scripts/build_plist.py + +# clean +RUN rm -rf ./scripts/ \ + # list contents + # todo - why is dockerignore not being respected? + && ls -a + +FROM scratch AS deploy # variables ARG PLUGIN_NAME="PlexyGlass.bundle" ARG PLUGIN_DIR="/config/Library/Application Support/Plex Media Server/Plug-ins" # add files from buildstage +# todo - add `--link` once hadolint supports this syntax, see https://github.com/hadolint/hadolint/issues/826 COPY --from=buildstage /build/ $PLUGIN_DIR/$PLUGIN_NAME