Remove extra build layers and reduce the existing ones by placing common actions in `base` layer
# limitations under the License.
# ------------------------------------------------------------------------
-# TODO check if it works with a newer version of Debian
-FROM alpine:3.8 as build
-WORKDIR /root
-RUN apk --update --no-cache add rsync pkgconf build-base autoconf automake python3=3.6.6-r0 protobuf=3.5.2-r0 libtool=2.4.6-r5 libffi-dev=3.2.1-r4 python3-dev=3.6.6-r0 zeromq-dev=4.2.3-r0 openssl-dev=1.0.2o-r2
-RUN pip3 install --upgrade pip
+FROM alpine:3.8 as base
+RUN apk --update --no-cache add --force python3=3.6.6-r0 libffi=3.2.1-r4 openssl=1.0.2o-r2 libzmq=4.2.3-r0
RUN mkdir /install
ENV PYTHONUSERBASE=/install
+WORKDIR /root
+
+FROM base as build
+RUN apk --update --no-cache add rsync pkgconf build-base autoconf automake protobuf=3.5.2-r0 libtool=2.4.6-r5 libffi-dev=3.2.1-r4 python3-dev=3.6.6-r0 zeromq-dev=4.2.3-r0 openssl-dev=1.0.2o-r2
+RUN pip3 install --upgrade pip
COPY ./requirements.txt .
RUN pip3 install --user -r ./requirements.txt
COPY ./remme/rest_api/swagger-index.patch .
@@ -35,10 +37,9 @@ RUN pip3 install --user ./remme
COPY ./tests ./tests
COPY ./bash /scripts
-FROM alpine:3.8 as release
-RUN apk --update --no-cache add --force python3=3.6.6-r0 libffi=3.2.1-r4 openssl=1.0.2o-r2 libzmq=4.2.3-r0
+FROM base as release
COPY --from=build /install /install
-ENV PYTHONUSERBASE=/install
+# Way to remove that
COPY ./bash /scripts
FROM hyperledger/sawtooth-validator:1.0.5 as validator
