From 1263da2172f9f6100dfb1a148d7f60e0e15183a0 Mon Sep 17 00:00:00 2001 From: Colin Nelson Date: Wed, 26 Sep 2018 09:18:23 -0700 Subject: [PATCH] Reduced loadgenerator's image size (#52) Reduce loadgenerator's image size from ~972MB to ~117MB * Changed loadgen.sh to execute with `/bin/sh` as opposed to `/bin/bash` * Changed dockerfile to a multi stage build * Changed base image to `python:3-alpine` as opposed to `python:3.6` --- src/loadgenerator/Dockerfile | 18 ++++++++++++++++-- src/loadgenerator/loadgen.sh | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/loadgenerator/Dockerfile b/src/loadgenerator/Dockerfile index a90c23e..b0004cf 100644 --- a/src/loadgenerator/Dockerfile +++ b/src/loadgenerator/Dockerfile @@ -1,7 +1,21 @@ -FROM python:3.6 +FROM python:3-alpine as base + +FROM base as builder + +RUN apk add --update --no-cache \ + gcc \ + linux-headers \ + make \ + musl-dev \ + python-dev \ + g++ COPY requirements.txt . -RUN pip install -r requirements.txt + +RUN pip install --install-option="--prefix=/install" -r requirements.txt + +FROM base +COPY --from=builder /install /usr/local COPY . . ENTRYPOINT ./loadgen.sh diff --git a/src/loadgenerator/loadgen.sh b/src/loadgenerator/loadgen.sh index 514174e..2a68db7 100755 --- a/src/loadgenerator/loadgen.sh +++ b/src/loadgenerator/loadgen.sh @@ -1,4 +1,4 @@ -#!/bin/bash -eu +#!/bin/sh -eu # # Copyright 2018 Google LLC #