Skip to content
Snippets Groups Projects
Verified Commit 5ad0b1f1 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

[Docker] Place all data under one volume.

Eases deployment, especially on hosters that charge per volume.
parent c21bfaa0
No related branches found
No related tags found
No related merge requests found
Pipeline #155 passed
......@@ -8,8 +8,9 @@ ENV PIP_DISABLE_PIP_VERSION_CHECK 1
ENV PIP_NO_CACHE_DIR 1
# Configure app settings for build and runtime
ENV BISCUIT_static__root /srv/static
ENV BISCUIT_media__root /srv/media
ENV BISCUIT_static__root /var/lib/biscuit/static
ENV BISCUIT_media__root /var/lib/biscuit/media
ENV BISCUIT_backup__location /var/lib/biscuit/backups
# FIXME Use poetry pre-release for external build
ENV POETRY_VERSION 1.0.0b3
......@@ -36,7 +37,7 @@ RUN pip install "poetry==$POETRY_VERSION"; \
# Install core
COPY biscuit ./biscuit/
COPY LICENSE README.md manage.py ./
RUN mkdir /etc/biscuit /srv/media /srv/static /var/backups/biscuit; \
RUN mkdir -p /var/lib/biscuit/media /var/lib/biscuit/static /var/lib/biscuit/backups; \
poetry build && pip install dist/*.whl
# Build messages and assets
......@@ -54,11 +55,8 @@ RUN apt-get remove --purge -y \
apt-get clean -y; \
rm -f /var/lib/apt/lists/*_*
# Mark configuration as mountableg from the host
VOLUME /etc/biscuit
VOLUME /srv/media
VOLUME /srv/static
VOLUME /var/backups/biscuit
# Declare a persistent volume for all data
VOLUME /var/lib/biscuit
# Define entrypoint and gunicorn running on port 8000
EXPOSE 8000
......
......@@ -6,11 +6,11 @@ export BISCUIT_database__host=${BISCUIT_database__host:-127.0.0.1}
export BISCUIT_database__port=${BISCUIT_database__port:-5432}
if [[ -z $BISCUIT_secret_key ]]; then
if [[ ! -e /etc/biscuit/secret_key ]]; then
touch /etc/biscuit/secret_key; chmod 600 /etc/biscuit/secret_key
LC_ALL=C tr -dc 'A-Za-z0-9!"#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~' </dev/urandom | head -c 64 >/etc/biscuit/secret_key
if [[ ! -e /var/lib/biscuit/secret_key ]]; then
touch /var/lib/biscuit/secret_key; chmod 600 /var/lib/biscuit/secret_key
LC_ALL=C tr -dc 'A-Za-z0-9!"#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~' </dev/urandom | head -c 64 >/var/lib/biscuit/secret_key
fi
BISCUIT_secret_key=$(</etc/biscuit/secret_key)
BISCUIT_secret_key=$(</var/lib/biscuit/secret_key)
fi
while ! nc -z $BISCUIT_database__host $BISCUIT_database__port; do
......
......@@ -6,4 +6,4 @@ COPY nginx.conf /etc/nginx/conf.d
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y libjs-bootstrap4 fonts-font-awesome libjs-jquery libjs-popper.js libjs-jquery-datatables
RUN mkdir /srv/media /srv/static
RUN mkdir /var/lib/biscuit
......@@ -13,11 +13,11 @@ server {
}
location /media/ {
alias /srv/media/;
alias /var/lib/biscuit/media/;
}
location /static/ {
alias /srv/static/;
alias /var/lib/biscuit/static/;
}
location /javascript/ {
......
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