From 19858595d616870026ec5129bf3cf4c2fd1dddfb Mon Sep 17 00:00:00 2001 From: azlux Date: Tue, 1 Dec 2020 01:30:04 +0100 Subject: [PATCH] Full Docker build (#234) * Added multi-stage docker build * switch dockerfile files Co-authored-by: ReAnzu --- Dockerfile.local | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Dockerfile.local diff --git a/Dockerfile.local b/Dockerfile.local new file mode 100644 index 0000000..d3d9225 --- /dev/null +++ b/Dockerfile.local @@ -0,0 +1,51 @@ +ARG ARCH= + +FROM ${ARCH}python:3-slim-buster AS source +ARG VERSION=master +ENV DEBIAN_FRONTEND=noninteractive +WORKDIR /botamusique +RUN apt-get update && apt-get install -y git +RUN git clone --recurse-submodules https://github.com/azlux/botamusique.git . && git checkout $VERSION + + +FROM ${ARCH}python:3-slim-buster AS python-builder +ENV DEBIAN_FRONTEND=noninteractive +WORKDIR /botamusique +RUN apt-get update \ + && apt-get install -y gcc ffmpeg libjpeg-dev libmagic-dev opus-tools zlib1g-dev \ + && rm -rf /var/lib/apt/lists/* +COPY --from=source /botamusique . +RUN python3 -m venv venv \ + && venv/bin/pip install wheel \ + && venv/bin/pip install -r requirements.txt + + +FROM ${ARCH}node:14-buster-slim AS node-builder +ENV DEBIAN_FRONTEND=noninteractive +WORKDIR /botamusique/web +COPY --from=source /botamusique/web . +RUN npm install +RUN npm run build + + +FROM ${ARCH}python:3-slim-buster AS template-builder +ENV DEBIAN_FRONTEND=noninteractive +WORKDIR /botamusique +COPY --from=python-builder /botamusique . +COPY --from=node-builder /botamusique/templates templates +RUN venv/bin/python scripts/translate_templates.py --lang-dir /botamusique/lang --template-dir /botamusique/templates + + +FROM ${ARCH}python:3-slim-buster +ENV DEBIAN_FRONTEND=noninteractive +EXPOSE 8181 +WORKDIR /botamusique +RUN apt-get update \ + && apt-get install -y ffmpeg libmagic-dev opus-tools zlib1g \ + && rm -rf /var/lib/apt/lists/* +COPY --from=python-builder /botamusique . +COPY --from=node-builder /botamusique/static static +COPY --from=template-builder /botamusique/templates templates +RUN chmod +x entrypoint.sh +ENTRYPOINT [ "/botamusique/entrypoint.sh" ] +CMD ["/botamusique/venv/bin/python", "/botamusique/mumbleBot.py"]