parent
37cf2191c1
commit
ae604765ef
@ -0,0 +1,44 @@
|
||||
FROM pythonmagick
|
||||
|
||||
ARG BACKEND_LOCATION="/opt"
|
||||
ARG DATA_LOCATION="/srv/photovoter"
|
||||
ARG USERNAME="changeme"
|
||||
ARG USERPASS="CHANGEME"
|
||||
|
||||
ENV BACKEND_LOCATION=${BACKEND_LOCATION}
|
||||
|
||||
# Required for python-regexp dependency
|
||||
RUN apt-get update && \
|
||||
apt-get upgrade && \
|
||||
apt-get install -y python3-dev gcc
|
||||
|
||||
# Pull backend
|
||||
RUN mkdir --parents $DATA_LOCATION/original $DATA_LOCATION/image && \
|
||||
cd $BACKEND_LOCATION && \
|
||||
git clone --depth=1 https://git.iamonlyherefortheicecream.ml/w2/photovoter_backend.git
|
||||
|
||||
# Install backend requirements
|
||||
RUN cd $BACKEND_LOCATION && \
|
||||
pip install --no-input --no-cache-dir -r photovoter_backend/requirements.txt && \
|
||||
pip install --no-input --no-cache-dir -r photovoter_backend/util/requirements.txt
|
||||
|
||||
# Clean up
|
||||
RUN apt-get remove --autoremove --purge -y gcc python3-dev && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Configure backend
|
||||
RUN sed --in-place \
|
||||
--expression 's#DATA_LOCATION = "/tmp/123"#DATA_LOCATION = "'$DATA_LOCATION'"#' \
|
||||
--expression 's#"testbox/photovoter.dblite"#"'$DATA_LOCATION'/photovoter.dblite"#' \
|
||||
--expression 's#CRED_USERNAME = "changeme"#CRED_USERNAME = "'$USERNAME'"#' \
|
||||
--expression 's#CRED_PASSWORD = "CHANGEME"#CRED_PASSWORD = "'$USERPASS'"#' \
|
||||
$BACKEND_LOCATION/photovoter_backend/config.py
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
WORKDIR ${BACKEND_LOCATION}/photovoter_backend
|
||||
CMD ["uvicorn", "main:app", "--host", "0.0.0.0"]
|
||||
@ -0,0 +1,51 @@
|
||||
FROM python:bullseye
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
ARG IM_VERSION=7.1.0-16
|
||||
ARG LIB_HEIF_VERSION=1.12.0
|
||||
ARG LIB_AOM_VERSION=3.2.0
|
||||
ARG LIB_WEBP_VERSION=1.2.1
|
||||
|
||||
RUN apt-get -y update && \
|
||||
apt-get -y upgrade && \
|
||||
apt-get install -y git make gcc pkg-config autoconf curl g++ \
|
||||
# libaom
|
||||
yasm cmake \
|
||||
# libheif
|
||||
libde265-0 libde265-dev libjpeg62-turbo libjpeg62-turbo-dev x265 libx265-dev libtool \
|
||||
# IM
|
||||
libpng16-16 libpng-dev libjpeg62-turbo libjpeg62-turbo-dev libgomp1 ghostscript libxml2-dev libxml2-utils libtiff-dev libfontconfig1-dev libfreetype6-dev fonts-dejavu && \
|
||||
# Building libwebp
|
||||
git clone https://chromium.googlesource.com/webm/libwebp && \
|
||||
cd libwebp && git checkout v${LIB_WEBP_VERSION} && \
|
||||
./autogen.sh && ./configure --enable-shared --enable-libwebpdecoder --enable-libwebpdemux --enable-libwebpmux --enable-static=no && \
|
||||
make && make install && \
|
||||
ldconfig /usr/local/lib && \
|
||||
cd ../ && rm -rf libwebp && \
|
||||
# Building libaom
|
||||
git clone https://aomedia.googlesource.com/aom && \
|
||||
cd aom && git checkout v${LIB_AOM_VERSION} && cd .. && \
|
||||
mkdir build_aom && \
|
||||
cd build_aom && \
|
||||
cmake ../aom/ -DENABLE_TESTS=0 -DBUILD_SHARED_LIBS=1 && make && make install && \
|
||||
ldconfig /usr/local/lib && \
|
||||
cd .. && \
|
||||
rm -rf aom && \
|
||||
rm -rf build_aom && \
|
||||
# Building libheif
|
||||
curl -L https://github.com/strukturag/libheif/releases/download/v${LIB_HEIF_VERSION}/libheif-${LIB_HEIF_VERSION}.tar.gz -o libheif.tar.gz && \
|
||||
tar -xzvf libheif.tar.gz && cd libheif-${LIB_HEIF_VERSION}/ && ./autogen.sh && ./configure && make && make install && cd .. && \
|
||||
ldconfig /usr/local/lib && \
|
||||
rm -rf libheif-${LIB_HEIF_VERSION} && rm libheif.tar.gz && \
|
||||
# Building ImageMagick
|
||||
git clone https://github.com/ImageMagick/ImageMagick.git && \
|
||||
cd ImageMagick && git checkout ${IM_VERSION} && \
|
||||
./configure --without-magick-plus-plus --disable-docs --disable-static --with-tiff && \
|
||||
make && make install && \
|
||||
ldconfig /usr/local/lib && \
|
||||
apt-get remove --autoremove --purge -y gcc make cmake curl g++ yasm autoconf pkg-config libpng-dev libjpeg62-turbo-dev libde265-dev libx265-dev libxml2-dev libtiff-dev libfontconfig1-dev libfreetype6-dev && \
|
||||
# Keep git and sqlite
|
||||
apt-get install -y git sqlite3 && \
|
||||
rm -rf /var/lib/apt/lists/* && \
|
||||
rm -rf /ImageMagick
|
||||
@ -0,0 +1,10 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
backend:
|
||||
image: photovoter-backend:latest
|
||||
ports:
|
||||
- "8000:8000"
|
||||
volumes:
|
||||
- ./photovoter_data:/srv/photovoter
|
||||
|
||||
Loading…
Reference in new issue