mirror of
https://github.com/nicolabs/nicobot.git
synced 2026-05-21 11:57:34 +02:00
~ Moving the most changing parts after the dependencies build so this layer can be reused to speed up the build
~ only copying explicit files (no more 'COPY . .') + also installing requirements-build.txt as its cleaner and might prevent bugs in the future (although it was not required because all build requirements are installed in a step before) + fixed : creating the .omemo directory to store OMEMO keys (XMPP backend) + adding default configuration files (less CLI parameters are therefore mandatory)
This commit is contained in:
parent
76ab6dd9aa
commit
1e8574cec2
|
|
@ -23,6 +23,7 @@ FROM python:3-alpine as builder
|
|||
# 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
|
||||
# XEdDSA needs at least make & cmake (future versions will not : see https://github.com/Syndace/python-xeddsa)
|
||||
#
|
||||
# build-base gcc ... : required to build Python dependencies
|
||||
# openjdk : javac to compile GetSystemProperty.java (to check the value of java.library.path)
|
||||
|
|
@ -46,16 +47,21 @@ RUN apk add --no-cache build-base gcc abuild binutils cmake \
|
|||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY . .
|
||||
|
||||
# This step WILL trigger a compilation on platforms without Python wheels
|
||||
# Builds & installs requirements (shoduld not change often)
|
||||
COPY requirements-*.txt \
|
||||
setup.py \
|
||||
.
|
||||
# This step WILL trigger a compilation on platforms without matching Python wheels
|
||||
RUN python3 -m pip install --no-cache-dir --user --upgrade pip && \
|
||||
python3 -m pip install --no-cache-dir --user -r requirements-runtime.txt .
|
||||
python3 -m pip install --no-cache-dir --user -r requirements-build.txt -r requirements-runtime.txt
|
||||
|
||||
# Not used currently (we just copy the /root/.local directory which has everyting thanks to the --user option)
|
||||
# Finally put (only runtime) compiled wheels under ./wheels/
|
||||
# https://pip.pypa.io/en/stable/user_guide/#installation-bundles
|
||||
#RUN pip wheel -r requirements-runtime.txt . --wheel-dir=wheels
|
||||
# Builds & installs nicobot (should change often, especially the .git directory)
|
||||
COPY LICENSE \
|
||||
README.md \
|
||||
.
|
||||
COPY nicobot nicobot
|
||||
COPY .git .git
|
||||
RUN python3 -m pip install --no-cache-dir --user .
|
||||
|
||||
|
||||
|
||||
|
|
@ -77,6 +83,9 @@ WORKDIR /usr/src/app
|
|||
# bash is to use extended syntax in entrypoint.sh (in particular tee >(...))
|
||||
RUN apk add --no-cache libressl-dev bash
|
||||
|
||||
# Required by slixmpp-omemo plugin
|
||||
RUN mkdir -p .omemo
|
||||
|
||||
# Not used currently (we just copy the /root/.local directory which has everyting thanks to the --user option)
|
||||
#COPY --from=builder /usr/src/app/wheels ./wheels
|
||||
#RUN pip install --no-cache-dir --force-reinstall --ignore-installed --upgrade --no-index wheels/*
|
||||
|
|
@ -86,11 +95,12 @@ ENV PATH=/root/.local/bin:$PATH
|
|||
# All Python files, including nicobot's ones
|
||||
COPY --from=builder /root/.local /root/.local/
|
||||
|
||||
# This script allows :
|
||||
# The 'docker-entrypoint.sh' script allows :
|
||||
# - packaging several bots in the same image (to be cleaner 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 layers)
|
||||
# - also adds extra command line options for Signal device linking
|
||||
# Otherwise the ENTRYPOINT would simply be [ "python"]
|
||||
COPY docker/docker-entrypoint.sh .
|
||||
# Also copying some default configuration files
|
||||
COPY docker/docker-entrypoint.sh docker/default-conf/* .
|
||||
ENTRYPOINT [ "./docker-entrypoint.sh" ]
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ RUN apt-get update && \
|
|||
apt-get install -y \
|
||||
# "make" tools required to compile the Python modules
|
||||
# not all may be required on all platforms...
|
||||
# XEdDSA needs at least make & cmake (future versions will not : see https://github.com/Syndace/python-xeddsa)
|
||||
cmake g++ make \
|
||||
# Rust is a requirement to build the 'cryptography' Python module
|
||||
# The recommended procedure is to use 'rustup but the both Debian &
|
||||
|
|
@ -28,16 +29,21 @@ RUN apt-get update && \
|
|||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY . .
|
||||
|
||||
# This step WILL trigger a compilation on platforms without Python wheels
|
||||
# Builds & installs requirements (shoduld not change often)
|
||||
COPY requirements-*.txt \
|
||||
setup.py \
|
||||
.
|
||||
# This step WILL trigger a compilation on platforms without matching Python wheels
|
||||
RUN python3 -m pip install --no-cache-dir --user --upgrade pip && \
|
||||
python3 -m pip install --no-cache-dir --user -r requirements-runtime.txt .
|
||||
python3 -m pip install --no-cache-dir --user -r requirements-build.txt -r requirements-runtime.txt
|
||||
|
||||
# Not used currently (we just copy the /root/.local directory which has everyting thanks to the --user option)
|
||||
# Finally put (only runtime) compiled wheels under ./wheels/
|
||||
# https://pip.pypa.io/en/stable/user_guide/#installation-bundles
|
||||
#RUN pip wheel -r requirements-runtime.txt . --wheel-dir=wheels
|
||||
# Builds & installs nicobot (should change often, especially the .git directory)
|
||||
COPY LICENSE \
|
||||
README.md \
|
||||
.
|
||||
COPY nicobot nicobot
|
||||
COPY .git .git
|
||||
RUN python3 -m pip install --no-cache-dir --user .
|
||||
|
||||
|
||||
|
||||
|
|
@ -53,6 +59,9 @@ FROM python:3-slim
|
|||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Required by slixmpp-omemo plugin
|
||||
RUN mkdir -p .omemo
|
||||
|
||||
# Not used currently (we just copy the /root/.local directory which has everyting thanks to the --user option)
|
||||
#COPY --from=builder /usr/src/app/wheels ./wheels
|
||||
#RUN pip install --no-cache-dir --force-reinstall --ignore-installed --upgrade --no-index wheels/*
|
||||
|
|
@ -62,11 +71,12 @@ ENV PATH=/root/.local/bin:$PATH
|
|||
# All Python files, including nicobot's ones
|
||||
COPY --from=builder /root/.local /root/.local/
|
||||
|
||||
# This script allows :
|
||||
# The 'docker-entrypoint.sh' script allows :
|
||||
# - packaging several bots in the same image (to be cleaner 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 layers)
|
||||
# - also adds extra command line options for Signal device linking
|
||||
# Otherwise the ENTRYPOINT would simply be [ "python"]
|
||||
COPY docker/docker-entrypoint.sh .
|
||||
# Also copying some default configuration files
|
||||
COPY docker/docker-entrypoint.sh docker/default-conf/* .
|
||||
ENTRYPOINT [ "./docker-entrypoint.sh" ]
|
||||
|
|
|
|||
Loading…
Reference in a new issue