Sign inSign up

hp5588/django-cms

By hp5588

•Updated over 7 years ago

configured to works with PostgreSQL

Image
0

956

hp5588/django-cms repository overview

⁠Warning

This is repository is for debugging use and not intended for production environment. For security concern, please configure with such setting DJANGO_DEBUG=False.

⁠Usage

⁠The following instruction only work under the same folder of docker-compose.yml
  1. create a file docker-compose.yml
  2. copy and past the content of following section (docker-compose file) into file
  3. sudo docker-compose up
    • to disable the stdout, add detach option -d
  4. open browser and heading to http://your_domain:8000
  5. login using admin/admin (user/password)
    • Maybe u would like to change the password

⁠Update

  1. sudo docker-compose down
  • this will delete container, however your data will persist in site_data and db_data volumes
  • DANGER!! to REMOVE ALL DATA, add -v option to also remove volumes which is define in docker-compose file
  1. To pull the latest image sudo docker-compose pull
  2. again sudo docker-compose up

⁠docker-compose.yml file as follow

version: '3'

services:
  db:
    image: postgres
    volumes:
      - db_data:/var/lib/postgresql/data
  web:
    image: hp5588/django-cms
    volumes:
      - site_data:/code
    ports:
      - "8000:8000"
    depends_on:
      - db
    environment:
      - HOST=<your domain>
      - SITE_NAME=mysite
volumes:
  site_data:
  db_data:

⁠Build Details

Following parts are already included in docker image (here only for reference)

⁠Dockerfile
FROM python:3
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code

COPY requirements.txt /code/

RUN \
python3 -m pip install virtualenv \
&& python3 -m virtualenv env \
&& . env/bin/activate \
&& pip install -r requirements.txt

COPY entrypoint.sh /code/
RUN chmod +x entrypoint.sh

CMD ["/bin/bash","entrypoint.sh"]
⁠entrypoint.sh
#!/bin/bash

#activate venv
source env/bin/activate

if [ ! -d "$SITE_NAME" ]; then
    # create site
    djangocms $SITE_NAME --db "postgres://postgres@db:5432/postgres"
fi

cd $SITE_NAME

# update setting
sed -i "s/^ALLOWED_HOSTS.*/ALLOWED_HOSTS = ["$HOST"]/m" $SITE_NAME/settings.py

python manage.py runserver 0.0.0.0:8000
⁠requirement.txt
Django>=2.0,<3.0
psycopg2-binary>=2.7,<3.0
djangocms-installer

Tag summary

Content type

Image

Digest

Size

367.1 MB

Last updated

over 7 years ago

docker pull hp5588/django-cms