mirror of
https://github.com/nicolabs/nicobot.git
synced 2025-09-07 05:14:01 +02:00
61 lines
2.6 KiB
Text
61 lines
2.6 KiB
Text
# This image is based on Alpine linux to get a minimum memory footprint
|
|
# Some say that alpine should not be used for Python (https://pythonspeed.com/articles/alpine-docker-python/),
|
|
# however given some additional work, overall it may be better in the end (https://nickjanetakis.com/blog/the-3-biggest-wins-when-using-alpine-as-a-base-docker-image)
|
|
# Currently this Dockerfile is not thoroughfully tested...
|
|
# Finally, a better option may probably be to just run the python scripts without any setup/install
|
|
# Also : Python version > 3.4.2
|
|
FROM python:3-alpine AS builder
|
|
|
|
# python:3-alpine misses gcc, ffi.h, ...
|
|
#
|
|
# GCC part :
|
|
# https://number1.co.za/alpine-python-docker-base-image-problem-with-gcc/
|
|
# https://wiki.alpinelinux.org/wiki/How_to_get_regular_stuff_working
|
|
#
|
|
# Python cryptography part :
|
|
# https://stackoverflow.com/questions/35736598/cannot-pip-install-cryptography-in-docker-alpine-linux-3-3-with-openssl-1-0-2g
|
|
# https://github.com/pyca/cryptography/blob/1340c00/docs/installation.rst#building-cryptography-on-linux
|
|
|
|
# Required to build
|
|
RUN apk add --no-cache build-base gcc abuild binutils cmake \
|
|
libressl-dev musl-dev libffi-dev
|
|
|
|
COPY requirements-runtime.txt .
|
|
RUN pip install --no-cache-dir --user -r requirements-runtime.txt
|
|
# It could be packaged (RUN python setup.py sdist bdist_wheel) to possibly
|
|
# improve size and speed ; probably as a multistage build
|
|
# And update the version from git using setuptools-scm
|
|
# But it requires a bit of work
|
|
#RUN python setup.py sdist bdist_wheel
|
|
|
|
|
|
|
|
FROM python:3-alpine
|
|
|
|
WORKDIR /usr/src/app
|
|
|
|
# Required at runtime
|
|
# libressl-dev : seems required for python to locate modules, or for omemo ?
|
|
RUN apk add --no-cache libressl-dev
|
|
|
|
COPY --from=builder /root/.local /root/.local/
|
|
#COPY --from=builder /root/.cache /root/.cache/
|
|
#COPY --from=builder /usr/local/lib /usr/local/lib/
|
|
# https://www.docker.com/blog/containerized-python-development-part-1/
|
|
# update PATH environment variable
|
|
#ENV PATH=/root/.local/bin:$PATH
|
|
|
|
# TODO How to do it with one COPY ?
|
|
|
|
# Or it could be COPY . . with a proper .dockerignore
|
|
# Or build the context as a preliminary step
|
|
COPY nicobot nicobot/
|
|
|
|
# This script allows packaging several bots in the same image
|
|
# (to be clean they could be in separate images but they're so close that it's a lot easier to package and does not waste space by duplicating images)
|
|
# Otherwise the ENTRYPOINT should simply be [ "python"]
|
|
# Made a a separate COPY because it's a docker-specific layer
|
|
# (other layers don't need to be re-built if this one changes)
|
|
COPY docker-entrypoint.sh .
|
|
ENTRYPOINT [ "./docker-entrypoint.sh" ]
|