Skip to content

Commit 8b43d8e

Browse files
authored
Removed use of setuptools in the docker image (#181)
* Removed use of setuptools in the docker image * Added forcefully delete pip from docker image
1 parent 4edcd50 commit 8b43d8e

File tree

1 file changed

+16
-32
lines changed

1 file changed

+16
-32
lines changed

Dockerfile

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,3 @@
1-
FROM python:3.10-alpine AS python-base
2-
3-
# install linux libraries necessary to compile some python packages
4-
RUN apk update && \
5-
apk add --no-cache bash build-base libffi-dev libressl-dev musl-dev zlib-dev gcompat
6-
7-
# BUILD STAGE ---------------------------------------
8-
# split this stage to save time and reduce image size
9-
# ---------------------------------------------------
10-
FROM python-base AS build
11-
12-
WORKDIR /app
13-
14-
# install python deps
15-
RUN pip install --upgrade pip
16-
17-
COPY requirements.txt requirements.txt
18-
RUN pip install --user -r requirements.txt
19-
20-
COPY horizon setup.py MANIFEST.in ./
21-
RUN python setup.py install --user
22-
231
# OPA BUILD STAGE -----------------------------------
242
# build opa from source or download precompiled binary
253
# ---------------------------------------------------
@@ -51,30 +29,32 @@ RUN if [ -f /custom/custom_opa.tar.gz ]; \
5129
# MAIN IMAGE ----------------------------------------
5230
# most of the time only this image should be built
5331
# ---------------------------------------------------
54-
FROM python-base
32+
FROM python:3.10-alpine
5533

5634
WORKDIR /app
5735

5836
RUN addgroup -S permit -g 1001
5937
RUN adduser -S -s /bin/bash -u 1000 -G permit -h /home/permit permit
6038

61-
# copy libraries from build stage
62-
RUN mkdir /home/permit/.local
63-
RUN mkdir /app/bin
64-
COPY --from=build /root/.local /home/permit/.local
39+
# install linux libraries necessary to compile some python packages
40+
RUN apk update && \
41+
apk add --no-cache bash build-base libffi-dev libressl-dev musl-dev zlib-dev gcompat
6542

43+
# Copy custom opa binary
44+
RUN mkdir /app/bin
45+
RUN chown -R permit:permit /app/bin
6646
COPY --from=opa_build --chmod=755 /opa /app/bin/opa
6747

6848
# bash is needed for ./start/sh script
6949
COPY scripts ./
7050

7151
RUN mkdir -p /config
72-
RUN chown -R permit:permit /app/bin
7352
RUN chown -R permit:permit /config
7453

7554
# copy wait-for-it (use only for development! e.g: docker compose)
7655
COPY scripts/wait-for-it.sh /usr/wait-for-it.sh
7756
RUN chmod +x /usr/wait-for-it.sh
57+
7858
# copy startup script
7959
COPY ./scripts/start.sh ./start.sh
8060
RUN chmod +x ./start.sh
@@ -85,14 +65,18 @@ USER permit
8565

8666
# copy Kong route-to-resource translation table
8767
COPY kong_routes.json /config/kong_routes.json
88-
# install sidecar package
8968

9069
# copy gunicorn_config
9170
COPY ./scripts/gunicorn_conf.py ./gunicorn_conf.py
92-
# copy app code
93-
COPY . ./
9471

95-
RUN pip uninstall -y pip setuptools
72+
# install python dependencies
73+
COPY ./requirements.txt ./requirements.txt
74+
RUN pip install -r requirements.txt
75+
RUN python -m pip uninstall -y pip setuptools
76+
RUN rm -r /usr/local/lib/python3.10/ensurepip
77+
78+
# copy app code
79+
COPY ./horizon ./horizon
9680

9781
# Make sure scripts in .local are usable:
9882
ENV PATH="/:/app/bin:/home/permit/.local/bin:$PATH"

0 commit comments

Comments
 (0)