61 lines
1.6 KiB
Text
61 lines
1.6 KiB
Text
# syntax=docker/dockerfile:1
|
|
|
|
ARG GOLANG_VERSION=1.24
|
|
ARG DEBIAN_VERSION=trixie
|
|
ARG PYTHON_VERSION=3.14
|
|
|
|
FROM docker.io/library/golang:${GOLANG_VERSION}-${DEBIAN_VERSION} AS gobuilder
|
|
|
|
RUN apt update
|
|
RUN apt -y install libolm-dev
|
|
|
|
RUN --mount=type=bind,source=./libmxclient/go.mod,target=/libmxclient/build/go.mod --mount=type=bind,source=./libmxclient/go.sum,target=/libmxclient/build/go.sum <<EOF
|
|
cd /libmxclient/build
|
|
go mod download
|
|
EOF
|
|
|
|
RUN --mount=type=bind,source=./libmxclient,target=/libmxclient/build <<EOF
|
|
cd /libmxclient/build
|
|
CGO_ENABLED=1 GOARCH=${GOARCH} go build -buildmode=c-shared -o /pygomx-build/libmxclient.so .
|
|
EOF
|
|
|
|
FROM docker.io/library/python:${PYTHON_VERSION}-${DEBIAN_VERSION} AS pybuilder
|
|
ENV PYTHONUNBUFFERED=1
|
|
ENV PIP_ROOT_USER_ACTION=ignore
|
|
COPY --from=gobuilder /pygomx-build/libmxclient.so /usr/local/lib/libmxclient.so
|
|
COPY --from=gobuilder /pygomx-build/libmxclient.h /usr/local/include/libmxclient.h
|
|
|
|
RUN pip install cffi setuptools
|
|
|
|
COPY pygomx /pygomx
|
|
|
|
RUN <<EOF
|
|
cd /pygomx
|
|
python3 build_ffi.py
|
|
ls -la *.so
|
|
EOF
|
|
|
|
FROM docker.io/library/python:${PYTHON_VERSION}-slim-${DEBIAN_VERSION} AS develop
|
|
ENV PYTHONUNBUFFERED=1
|
|
ENV PIP_ROOT_USER_ACTION=ignore
|
|
RUN pip install cffi
|
|
|
|
RUN <<EOF
|
|
apt update
|
|
apt -y upgrade
|
|
apt -y install libolm3
|
|
rm -rf /var/lib/apt/lists/*
|
|
EOF
|
|
|
|
COPY --from=gobuilder /pygomx-build/libmxclient.so /usr/local/lib/
|
|
COPY --from=pybuilder /pygomx/_pygomx.cpython-314-x86_64-linux-gnu.so /usr/local/lib/python3.14/site-packages/
|
|
RUN ldconfig
|
|
|
|
FROM develop AS demobot
|
|
WORKDIR /smal
|
|
COPY smal /smal
|
|
RUN pip install .
|
|
|
|
WORKDIR /demobot
|
|
|
|
CMD [ "demobot" ]
|