-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from MelonSmasher/docker-slimdown
Reduced docker image size from 883 MB to 32MB!
- Loading branch information
Showing
2 changed files
with
29 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ config.example.json | |
config.json | ||
piProbe.service | ||
.git | ||
.gitignore | ||
.gitignore | ||
requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,34 @@ | ||
FROM balenalib/raspberrypi3-python:3-build | ||
### | ||
# Build image | ||
### | ||
FROM balenalib/raspberrypi3-alpine-python:3-latest as build | ||
|
||
WORKDIR /usr/src/app | ||
ENV LIBRARY_PATH=/lib:/usr/lib | ||
ENV ADAFRUIT_DHT_PY_VERSION=1.4.0 | ||
ENV INFLUXDB_PY_VERSION=5.2.2 | ||
ENV CX_FREEZE_PY_VERSION=6.0b1 | ||
|
||
WORKDIR /usr/src/build | ||
|
||
COPY piProbe.py piProbe.py | ||
|
||
COPY requirements.txt requirements.txt | ||
RUN apk add --no-cache build-base python3 python3-dev py3-openssl | ||
RUN python3 -m pip install --no-cache-dir --trusted-host pypi.python.org cx_Freeze==${CX_FREEZE_PY_VERSION} | ||
RUN python3 -m pip install --no-cache-dir --trusted-host pypi.python.org influxdb==${INFLUXDB_PY_VERSION} | ||
RUN python3 -m pip install --no-cache-dir --trusted-host pypi.python.org Adafruit_DHT==${ADAFRUIT_DHT_PY_VERSION} --install-option="--force-pi2" | ||
RUN cxfreeze piProbe.py --target-dir dist --include-modules=multiprocessing,os,sys,influxdb,Adafruit_DHT,requests,idna.idnadata,urllib3 | ||
|
||
### | ||
# Deployed image | ||
### | ||
FROM arm32v7/alpine:3.9 | ||
|
||
RUN apt-get update \ | ||
&& apt-get upgrade --yes \ | ||
&& apt-get install build-essential python-dev python-openssl python-pip -y \ | ||
&& pip3 install --no-cache-dir --trusted-host pypi.python.org -r requirements.txt | ||
ENV AM_I_IN_A_DOCKER_CONTAINER=Yes | ||
ENV LIBRARY_PATH=/lib:/usr/lib | ||
|
||
WORKDIR /usr/src/app | ||
|
||
ENV AM_I_IN_A_DOCKER_CONTAINER Yes | ||
# Copy precompiled binary | ||
COPY --from=build /usr/src/build/dist/ ./ | ||
|
||
CMD modprobe w1-gpio && modprobe w1-therm modprobe i2c-dev && python3 piProbe.py | ||
CMD modprobe w1-gpio && modprobe w1-therm && modprobe i2c-dev && ./piProbe |