Skip to content
Snippets Groups Projects
Commit 5b41df20 authored by Tom Teichler's avatar Tom Teichler :beers:
Browse files

Merge branch '398-docker-provide-aleksis-base-image' into 'master'

Resolve "[Docker] Provide AlekSIS base image"

Closes #398

See merge request !511
parents cf471364 a6c675d6
No related branches found
No related tags found
1 merge request!511Resolve "[Docker] Provide AlekSIS base image"
Pipeline #6209 passed
......@@ -9,6 +9,8 @@ include:
file: /ci/test/security.yml
- project: "AlekSIS/official/AlekSIS"
file: /ci/build/dist.yml
- project: "AlekSIS/official/AlekSIS"
file: /ci/build/docker.yml
- project: "AlekSIS/official/AlekSIS"
file: /ci/deploy/pages.yml
- project: "AlekSIS/official/AlekSIS"
......
FROM python:3.9-buster AS core
# Configure Python to be nice inside Docker and pip to stfu
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
ENV PIP_DEFAULT_TIMEOUT 100
ENV PIP_DISABLE_PIP_VERSION_CHECK 1
ENV PIP_NO_CACHE_DIR 1
ENV PIP_EXTRA_INDEX_URL https://edugit.org/api/v4/projects/461/packages/pypi/simple
ENV PIP_USE_DEPRECATED legacy-resolver
# Configure app settings for build and runtime
ENV ALEKSIS_static__root /usr/share/aleksis/static
ENV ALEKSIS_media__root /var/lib/aleksis/media
ENV ALEKSIS_backup__location /var/lib/aleksis/backups
# Install necessary Debian and PyPI packages for build and runtime
RUN apt-get -y update && \
apt-get -y install eatmydata && \
eatmydata apt-get -y upgrade && \
eatmydata apt-get install -y --no-install-recommends \
build-essential \
gettext \
libpq5 \
libpq-dev \
libssl-dev \
netcat-openbsd \
yarnpkg && \
eatmydata pip install gunicorn django-compressor
# Install extra dependencies
ARG EXTRAS="ldap"
RUN case ",$EXTRAS," in \
(*",ldap,"*) \
eatmydata apt-get install -y --no-install-recommends \
libldap2-dev \
libsasl2-dev \
ldap-utils \
;; \
esac
# Install core
RUN set -e; \
mkdir -p /var/lib/aleksis/media /usr/share/aleksis/static /var/lib/aleksis/backups; \
eatmydata pip install AlekSIS-Core\[$EXTRAS\]
# Declare a persistent volume for all data
VOLUME /var/lib/aleksis
# Define entrypoint and gunicorn running on port 8000
EXPOSE 8000
COPY docker-entrypoint.sh /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
# Install assets
FROM core as assets
RUN eatmydata aleksis-admin yarn install
# Clean up build dependencies
FROM assets AS clean
RUN set -e; \
eatmydata apt-get remove --purge -y \
build-essential \
gettext \
libpq-dev \
libssl-dev \
libldap2-dev \
libsasl2-dev \
yarnpkg; \
eatmydata apt-get autoremove --purge -y; \
apt-get clean -y; \
rm -f /var/lib/apt/lists/*_*; \
rm -rf /root/.cache
#!/bin/bash
GUNICORN_BIND=${GUNICORN_BIND:-0.0.0.0:8000}
export ALEKSIS_database__host=${ALEKSIS_database__host:-127.0.0.1}
export ALEKSIS_database__port=${ALEKSIS_database__port:-5432}
if [[ -z $ALEKSIS_secret_key ]]; then
if [[ ! -e /var/lib/aleksis/secret_key ]]; then
touch /var/lib/aleksis/secret_key; chmod 600 /var/lib/aleksis/secret_key
LC_ALL=C tr -dc 'A-Za-z0-9!"#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~' </dev/urandom | head -c 64 >/var/lib/aleksis/secret_key
fi
ALEKSIS_secret_key=$(</var/lib/aleksis/secret_key)
fi
while ! nc -z $ALEKSIS_database__host $ALEKSIS_database__port; do
sleep 0.1
done
aleksis-admin compilescss
aleksis-admin collectstatic --no-input --clear
aleksis-admin migrate
aleksis-admin createinitialrevisions
ARG=${$1:-"gunicorn"}
if [ $ARG = "celery_worker" ]; then
exec celery -A aleksis.core worker -l info
elif [ $ARG = "celery_beat" ]; then
exec celery -A aleksis.core beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler
else
exec gunicorn aleksis.core.wsgi --bind ${GUNICORN_BIND}
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment