Simplify package management for python services (#120)
This PR does a few things: 1. **Removes unnecessary Python dependencies currently being installed for `emailservice`** There are quite a few packages being installed that aren't actual dependencies. 2. **Removes a number of related, also unnecessary system-level dependencies for `emailservice`** These were a result of the Python dependencies that are unnecessary. 3. **Pins all of the sub-dependencies for `loadgenerator`** This is good practice to ensure that things don't break one day in the future when a newer version of an unpinned sub-dependenency is released. 4. **Compile all Python dependencies from `requirements.in` files** This is mostly bookkeeping. It allows us to only specify the top-level dependencies we care about in the requirements.in files, which are then compiled to frozen dependencies in the requirements.txt files. This ensures that we only install the dependencies we need, and that we're not missing any unpinned sub-dependencies. It also makes it more clear where our sub-dependencies are coming from. 5. **Switch to -slim images from -alpine** Python's built distribution format (wheel) is incompatible with alpine-based images, causing dependencies like `grpcio` to be compiled from scratch, rather than from a pre-built wheel. This should improve or possibly fix #58, while keeping the image size roughly the same: ``` emailservice latest d1b818eabe05 6 seconds ago 286MB loadgenerator latest 4d9b5acbfbbb 6 seconds ago 125MB ```
This commit is contained in:
parent
823e993104
commit
aaf2f8717d
6 changed files with 64 additions and 65 deletions
|
@ -1,21 +1,7 @@
|
|||
FROM python:3-alpine as base
|
||||
FROM python:3-slim as base
|
||||
|
||||
FROM base as builder
|
||||
|
||||
# gRPC and app deps
|
||||
RUN apk add --update --no-cache \
|
||||
gcc \
|
||||
linux-headers \
|
||||
make \
|
||||
musl-dev \
|
||||
python-dev \
|
||||
g++ \
|
||||
# App Deps
|
||||
cairo-dev \
|
||||
cairo \
|
||||
openssl-dev \
|
||||
gobject-introspection-dev
|
||||
|
||||
# get packages
|
||||
COPY requirements.txt .
|
||||
RUN pip install -r requirements.txt
|
||||
|
@ -25,6 +11,10 @@ FROM base as final
|
|||
# Enable unbuffered logging
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
|
||||
RUN apt-get -qq update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
wget
|
||||
|
||||
# Download the grpc health probe
|
||||
RUN GRPC_HEALTH_PROBE_VERSION=v0.2.0 && \
|
||||
wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \
|
||||
|
@ -35,9 +25,6 @@ WORKDIR /email_server
|
|||
# Grab packages from builder
|
||||
COPY --from=builder /usr/local/lib/python3.7/ /usr/local/lib/python3.7/
|
||||
|
||||
# Need libstdc++ for grpc
|
||||
RUN apk add --no-cache libstdc++
|
||||
|
||||
# Add the application
|
||||
COPY . .
|
||||
|
||||
|
|
6
src/emailservice/requirements.in
Normal file
6
src/emailservice/requirements.in
Normal file
|
@ -0,0 +1,6 @@
|
|||
google-api-core==1.6.0
|
||||
grpcio-health-checking==1.12.1
|
||||
grpcio==1.16.1
|
||||
jinja2==2.10
|
||||
opencensus[stackdriver]==0.1.10
|
||||
python-json-logger==0.1.9
|
|
@ -1,41 +1,29 @@
|
|||
asn1crypto==0.24.0
|
||||
cachetools==2.1.0
|
||||
certifi==2018.8.24
|
||||
cffi==1.11.5
|
||||
chardet==3.0.4
|
||||
configparser==3.5.0
|
||||
cryptography==2.3.1
|
||||
entrypoints==0.2.3
|
||||
enum34==1.1.6
|
||||
futures==3.1.1
|
||||
google-api-core==1.6.0
|
||||
google-auth==1.6.1
|
||||
google-cloud-core==0.29.0
|
||||
googleapis-common-protos==1.5.3
|
||||
grpc-google-iam-v1==0.11.4
|
||||
grpcio==1.16.1
|
||||
#
|
||||
# This file is autogenerated by pip-compile
|
||||
# To update, run:
|
||||
#
|
||||
# pip-compile --output-file requirements.txt requirements.in
|
||||
#
|
||||
cachetools==3.0.0 # via google-auth
|
||||
certifi==2018.11.29 # via requests
|
||||
chardet==3.0.4 # via requests
|
||||
google-api-core[grpc]==1.6.0
|
||||
google-auth==1.6.2 # via google-api-core
|
||||
google-cloud-core==0.29.1 # via google-cloud-trace
|
||||
google-cloud-trace==0.20.2 # via opencensus
|
||||
googleapis-common-protos==1.5.5 # via google-api-core
|
||||
grpcio-health-checking==1.12.1
|
||||
grpcio-tools==1.12.1
|
||||
idna==2.7
|
||||
ipaddress==1.0.22
|
||||
jeepney==0.4
|
||||
Jinja2==2.10
|
||||
keyring==15.1.0
|
||||
keyrings.alt==3.1
|
||||
MarkupSafe==1.0
|
||||
grpcio==1.16.1
|
||||
idna==2.8 # via requests
|
||||
jinja2==2.10
|
||||
markupsafe==1.1.0 # via jinja2
|
||||
opencensus[stackdriver]==0.1.10
|
||||
protobuf==3.6.1
|
||||
pyasn1==0.4.4
|
||||
pyasn1-modules==0.2.2
|
||||
pycairo==1.17.1
|
||||
pycparser==2.19
|
||||
pycrypto==2.6.1
|
||||
PyGObject==3.30.1
|
||||
protobuf==3.6.1 # via google-api-core, googleapis-common-protos, grpcio-health-checking
|
||||
pyasn1-modules==0.2.3 # via google-auth
|
||||
pyasn1==0.4.5 # via pyasn1-modules, rsa
|
||||
python-json-logger==0.1.9
|
||||
pytz==2018.5
|
||||
pyxdg==0.26
|
||||
requests==2.20.0
|
||||
rsa==4.0
|
||||
SecretStorage==3.1.0
|
||||
six==1.11.0
|
||||
urllib3==1.23
|
||||
pytz==2018.9 # via google-api-core
|
||||
requests==2.21.0 # via google-api-core
|
||||
rsa==4.0 # via google-auth
|
||||
six==1.12.0 # via google-api-core, google-auth, grpcio, protobuf
|
||||
urllib3==1.24.1 # via requests
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
FROM python:3-alpine as base
|
||||
FROM python:3-slim as base
|
||||
|
||||
FROM base as builder
|
||||
|
||||
RUN apk add --update --no-cache \
|
||||
gcc \
|
||||
linux-headers \
|
||||
make \
|
||||
musl-dev \
|
||||
python-dev \
|
||||
RUN apt-get -qq update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
g++
|
||||
|
||||
COPY requirements.txt .
|
||||
|
|
1
src/loadgenerator/requirements.in
Normal file
1
src/loadgenerator/requirements.in
Normal file
|
@ -0,0 +1 @@
|
|||
locustio==0.8.1
|
|
@ -1,2 +1,23 @@
|
|||
#
|
||||
# This file is autogenerated by pip-compile
|
||||
# To update, run:
|
||||
#
|
||||
# pip-compile --output-file requirements.txt requirements.in
|
||||
#
|
||||
certifi==2018.11.29 # via requests
|
||||
chardet==3.0.4 # via requests
|
||||
click==7.0 # via flask
|
||||
flask==1.0.2 # via locustio
|
||||
gevent==1.4.0 # via locustio
|
||||
greenlet==0.4.15 # via gevent
|
||||
idna==2.8 # via requests
|
||||
itsdangerous==1.1.0 # via flask
|
||||
jinja2==2.10 # via flask
|
||||
locustio==0.8.1
|
||||
pyzmq==17.0.0
|
||||
markupsafe==1.1.0 # via jinja2
|
||||
msgpack-python==0.5.6 # via locustio
|
||||
pyzmq==17.0.0 # via locustio
|
||||
requests==2.21.0 # via locustio
|
||||
six==1.12.0 # via locustio
|
||||
urllib3==1.24.1 # via requests
|
||||
werkzeug==0.14.1 # via flask
|
||||
|
|
Loading…
Reference in a new issue