diff --git a/tools/build-server-image.sh b/tools/build-server-image.sh new file mode 100755 index 0000000..10b199d --- /dev/null +++ b/tools/build-server-image.sh @@ -0,0 +1,4 @@ +#!/bin/sh +TAG="${1:-eteserver}" +TOOLS_DIR="$(dirname "$0")" +exec podman build -t "${TAG}" -f "${TOOLS_DIR}/server.containerfile" "${TOOLS_DIR}/../server" diff --git a/tools/server.containerfile b/tools/server.containerfile new file mode 100644 index 0000000..9910c76 --- /dev/null +++ b/tools/server.containerfile @@ -0,0 +1,30 @@ +FROM python:3.11-alpine + +ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \ + PIP_NO_CACHE_DIR=1 \ + PIP_ROOT_USER_ACTION=ignore + +# install system pkg deps +RUN apk add libpq postgresql-dev --virtual .build-deps coreutils gcc libc-dev libffi-dev make + +COPY etebase_server/ /app/etebase_server/ +COPY requirements.txt manage.py /app/ +WORKDIR /app + +# 1. install app pip requirements +# 2. generate static files +# 3. cleanup +RUN pip install -U pip && \ + pip install --no-cache-dir --progress-bar off -r ./requirements.txt && \ + pip install --no-cache-dir --progress-bar off psycopg2==2.9.6 && \ + \ + python manage.py collectstatic --noinput && \ + \ + apk del .build-deps make gcc coreutils && \ + apk add libpq && \ + rm -rf /root/.cache + +ENV ETEBASE_EASY_CONFIG_PATH=/app/server.conf +VOLUME /data + +ENTRYPOINT ["uvicorn", "etebase_server.asgi:application"]