Commit bc22f77c authored by Guillaume Bernard's avatar Guillaume Bernard Committed by Guillaume Bernard

feat #85: use Damned Lies in Docker

- Provide a Dockerfile to build an image that includes requirements.
- Start Damned Lies using docker-compose
parent 92112c42
Pipeline #64859 passed with stage
in 4 minutes and 47 seconds
FROM python:slim
MAINTAINER Guillaume Bernard <associations@guillaume-bernard.fr>
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
# Let this first for caching reasons
RUN apt update && \
apt install -y gettext intltool gnome-doc-utils itstool libmariadbclient-dev libicu-dev build-essential
# Implicitely creates /damnedlies directory
WORKDIR /damnedlies
COPY requirements.txt /damnedlies/requirements.txt
RUN pip3 install -r requirements.txt
COPY . /damnedlies/
ENTRYPOINT /damnedlies/docker-entrypoint.sh
version: "3"
services:
damned-lies:
build: .
image: damned-lies
container_name: damned-lies
hostname: damned-lies
environment:
- DJANGO_ROOT_LOGIN=root
- DJANGO_ROOT_PASSWORD=root
ports:
- 8080:8080
volumes:
- .:/damnedlies
entrypoint: /damnedlies/docker-entrypoint.sh
#!/bin/bash
# Initialize SECRET_KEY for Django if none is already given
local_settings="./damnedlies/local_settings.py"
if ! grep 'SECRET_KEY' "${local_settings}" &> /dev/null ; then
echo "SECRET_KEY = 'supersecretkey'" >> "${local_settings}"
fi
# Prepare database migration
python3 ./manage.py migrate
# Create super user with root and root credentials
python3 ./manage.py shell <<< "
from django.contrib.auth.models import User
if User.objects.filter(username='${DJANGO_ROOT_LOGIN}').count() == 0:
User.objects.create_superuser('${DJANGO_ROOT_LOGIN}', '', '${DJANGO_ROOT_PASSWORD}')
"
# Load sample data into database
python3 ./manage.py loaddata sample_data
# Run webserver
python3 ./manage.py runserver 0.0.0.0:8080
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment