├── .env ├── .gitignore ├── LICENSE ├── README.md ├── docker-compose.yml ├── nginx ├── Dockerfile └── sites-enabled │ └── mezzanine └── web ├── Dockerfile ├── __init__.py ├── docker_mezzanine ├── __init__.py ├── local_settings.py ├── settings.py ├── urls.py └── wsgi.py ├── manage.py ├── requirements.txt ├── start.sh └── templates └── index.html /.env: -------------------------------------------------------------------------------- 1 | # Mezzanine API Docker Environment Variables 2 | 3 | # Enable debugging only during development. 4 | DEBUG=True 5 | 6 | # Secret keys: make these unique and don't share them with anybody. 7 | SECRET_KEY=g2-l8vr#+tq&-mb=#@+)f!c#&cbj%hosdp--883_9c&_hx%x+5 8 | NEVERCACHE_KEY=%h(e0^9-iqts=t@z!)vu@)+=jqiy)7^411$)u_3@%u7#8#$ox9 9 | 10 | # Docker PostgreSQL Database. 11 | DB_NAME=postgres 12 | DB_USER=postgres 13 | DB_PASS=postgres 14 | DB_SERVICE=postgres 15 | DB_PORT=5432 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | *.db 3 | __pycache__ 4 | .DS_Store 5 | web/static/ 6 | 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 George Cushen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker for Mezzanine CMS + API 2 | 3 | Mezzanine API Docker is an instance of [Mezzanine CMS](http://mezzanine.jupo.org/) with the [REST API](http://gcushen.github.io/mezzanine-api/) which runs within Docker containers. 4 | 5 | Three microservices are created, for *Mezzanine itself*, the *PostgreSQL database*, and the *Nginx web server*. 6 | 7 | ## Prerequisites 8 | 9 | The following Docker products should be installed: 10 | 11 | - [Docker Engine](https://docs.docker.com/engine/installation/) 12 | - [Docker Compose](https://docs.docker.com/compose/install/) 13 | - [Docker Machine](https://docs.docker.com/machine/install-machine/) 14 | 15 | ## Installation 16 | 17 | To setup Mezzanine CMS with the REST API as Docker microservices: 18 | 19 | 1. Download this Mezzanine Docker project with `git`: 20 | 21 | git clone https://github.com/gcushen/mezzanine-api-docker.git 22 | cd mezzanine-api-docker 23 | 24 | 1. Create a new docker machine: 25 | 26 | docker-machine create -d virtualbox mezzanine 27 | 28 | 1. Build the images: 29 | 30 | docker-compose build 31 | 32 | 1. Start the microservices: 33 | 34 | docker-compose up -d 35 | 36 | 1. Open the URL given by the following command in your web browser: 37 | 38 | echo "http://$(docker-machine ip mezzanine)/" 39 | 40 | Login to the admin panel with username `admin` and password `default`. 41 | 42 | ## Getting Started 43 | 44 | View the [documentation website](http://gcushen.github.io/mezzanine-api/#getting-started) or explore the [remote command line tool](http://gcushen.github.io/mezzanine-api/cli/) and [remote SDK](http://gcushen.github.io/mezzanine-api/client/). 45 | 46 | ## Community 47 | 48 | Feel free to [star](https://github.com/gcushen/mezzanine-api-docker) Mezzanine API Docker on Github to show your support and monitor updates. 49 | 50 | Join us in the [Mezzanine API chat room](https://gitter.im/gcushen/mezzanine-api?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) or leave a message and we will try to get back to you. 51 | 52 | Please file a [ticket](https://github.com/gcushen/mezzanine-api-docker/issues) or contribute a pull request on GitHub for bugs or feature requests. 53 | 54 | ## License 55 | 56 | Created by [George Cushen](http://cushen.me). 57 | 58 | Released under the [MIT](https://github.com/gcushen/mezzanine-api-docker/blob/master/LICENSE) license. 59 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | # Docker for Mezzanine CMS + REST API 2 | version: '2' 3 | 4 | services: 5 | # A microservice for the web app. 6 | web: 7 | container_name: web 8 | restart: always 9 | build: ./web 10 | expose: 11 | - "8000" 12 | links: 13 | - postgres:postgres 14 | depends_on: 15 | - postgres 16 | volumes: 17 | - ./web/static:/usr/src/app/static 18 | - ./web/static/media:/usr/src/app/static/media 19 | env_file: .env 20 | command: /start.sh 21 | 22 | # A microservice for the web server. 23 | nginx: 24 | container_name: nginx 25 | restart: always 26 | build: ./nginx 27 | ports: 28 | - "80:80" 29 | volumes: 30 | - /www/static 31 | - /www/static/media 32 | volumes_from: 33 | - web 34 | links: 35 | - web:web 36 | 37 | # A microservice for the database. 38 | postgres: 39 | container_name: postgres 40 | restart: always 41 | image: postgres:latest 42 | ports: 43 | - "5432:5432" 44 | #volumes: 45 | # - pgdata:/var/lib/postgresql/data/ 46 | -------------------------------------------------------------------------------- /nginx/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM tutum/nginx 2 | MAINTAINER George Cushen 3 | 4 | RUN rm /etc/nginx/sites-enabled/default 5 | ADD sites-enabled/ /etc/nginx/sites-enabled 6 | -------------------------------------------------------------------------------- /nginx/sites-enabled/mezzanine: -------------------------------------------------------------------------------- 1 | server { 2 | 3 | listen 80; 4 | server_name example.org; 5 | charset utf-8; 6 | 7 | location /static { 8 | alias /usr/src/app/static; 9 | } 10 | 11 | location /static/media { 12 | alias /usr/src/app/static/media; 13 | } 14 | 15 | location / { 16 | proxy_pass http://web:8000; 17 | proxy_set_header Host $host; 18 | proxy_set_header X-Real-IP $remote_addr; 19 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 20 | } 21 | 22 | } -------------------------------------------------------------------------------- /web/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.5-onbuild 2 | MAINTAINER George Cushen 3 | 4 | # Install Mezzanine dependencies. 5 | RUN sed "s/^deb\ /deb-src /g" /etc/apt/sources.list >> /etc/apt/sources.list && \ 6 | DEBIAN_FRONTEND=noninteractive apt-get clean && apt-get update && \ 7 | apt-get install -y \ 8 | libjpeg-dev &&\ 9 | apt-get build-dep -y \ 10 | python-imaging 11 | 12 | ENV DOCKERIZE_VERSION v0.2.0 13 | RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ 14 | && tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz 15 | 16 | # Add start script 17 | ADD ./start.sh / 18 | -------------------------------------------------------------------------------- /web/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcushen/mezzanine-api-docker/7b699b27e082f9c331212f9e242e72552aa96fff/web/__init__.py -------------------------------------------------------------------------------- /web/docker_mezzanine/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcushen/mezzanine-api-docker/7b699b27e082f9c331212f9e242e72552aa96fff/web/docker_mezzanine/__init__.py -------------------------------------------------------------------------------- /web/docker_mezzanine/local_settings.py: -------------------------------------------------------------------------------- 1 | # This file is exec'd from settings.py, so it has access to and can 2 | # modify all the variables in settings.py. 3 | 4 | # If this file is changed in development, the development server will 5 | # have to be manually restarted because changes will not be noticed 6 | # immediately. 7 | 8 | # Disable debugging unless defined otherwise through environment variable. 9 | DEBUG = True if os.getenv('DEBUG') == 'true' else False 10 | 11 | WSGI_APPLICATION = 'docker_mezzanine.wsgi.application' 12 | 13 | # Secret keys: make these unique, and don't share them with anybody. 14 | SECRET_KEY = os.environ['SECRET_KEY'] 15 | NEVERCACHE_KEY = os.environ['NEVERCACHE_KEY'] 16 | 17 | # Docker PostgreSQL Database. 18 | DATABASES = { 19 | 'default': { 20 | 'ENGINE': 'django.db.backends.postgresql_psycopg2', 21 | 'NAME': os.environ['DB_NAME'], 22 | 'USER': os.environ['DB_USER'], 23 | 'PASSWORD': os.environ['DB_PASS'], 24 | 'HOST': os.environ['DB_SERVICE'], 25 | 'PORT': os.environ['DB_PORT'] 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /web/docker_mezzanine/settings.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, unicode_literals 2 | import os 3 | 4 | from django import VERSION as DJANGO_VERSION 5 | from django.utils.translation import ugettext_lazy as _ 6 | 7 | 8 | ###################### 9 | # MEZZANINE SETTINGS # 10 | ###################### 11 | 12 | # The following settings are already defined with default values in 13 | # the ``defaults.py`` module within each of Mezzanine's apps, but are 14 | # common enough to be put here, commented out, for conveniently 15 | # overriding. Please consult the settings documentation for a full list 16 | # of settings Mezzanine implements: 17 | # http://mezzanine.jupo.org/docs/configuration.html#default-settings 18 | 19 | # Controls the ordering and grouping of the admin menu. 20 | # 21 | # ADMIN_MENU_ORDER = ( 22 | # ("Content", ("pages.Page", "blog.BlogPost", 23 | # "generic.ThreadedComment", (_("Media Library"), "media-library"),)), 24 | # ("Site", ("sites.Site", "redirects.Redirect", "conf.Setting")), 25 | # ("Users", ("auth.User", "auth.Group",)), 26 | # ) 27 | 28 | # A three item sequence, each containing a sequence of template tags 29 | # used to render the admin dashboard. 30 | # 31 | # DASHBOARD_TAGS = ( 32 | # ("blog_tags.quick_blog", "mezzanine_tags.app_list"), 33 | # ("comment_tags.recent_comments",), 34 | # ("mezzanine_tags.recent_actions",), 35 | # ) 36 | 37 | # A sequence of templates used by the ``page_menu`` template tag. Each 38 | # item in the sequence is a three item sequence, containing a unique ID 39 | # for the template, a label for the template, and the template path. 40 | # These templates are then available for selection when editing which 41 | # menus a page should appear in. Note that if a menu template is used 42 | # that doesn't appear in this setting, all pages will appear in it. 43 | 44 | # PAGE_MENU_TEMPLATES = ( 45 | # (1, _("Top navigation bar"), "pages/menus/dropdown.html"), 46 | # (2, _("Left-hand tree"), "pages/menus/tree.html"), 47 | # (3, _("Footer"), "pages/menus/footer.html"), 48 | # ) 49 | 50 | # A sequence of fields that will be injected into Mezzanine's (or any 51 | # library's) models. Each item in the sequence is a four item sequence. 52 | # The first two items are the dotted path to the model and its field 53 | # name to be added, and the dotted path to the field class to use for 54 | # the field. The third and fourth items are a sequence of positional 55 | # args and a dictionary of keyword args, to use when creating the 56 | # field instance. When specifying the field class, the path 57 | # ``django.models.db.`` can be omitted for regular Django model fields. 58 | # 59 | # EXTRA_MODEL_FIELDS = ( 60 | # ( 61 | # # Dotted path to field. 62 | # "mezzanine.blog.models.BlogPost.image", 63 | # # Dotted path to field class. 64 | # "somelib.fields.ImageField", 65 | # # Positional args for field class. 66 | # (_("Image"),), 67 | # # Keyword args for field class. 68 | # {"blank": True, "upload_to": "blog"}, 69 | # ), 70 | # # Example of adding a field to *all* of Mezzanine's content types: 71 | # ( 72 | # "mezzanine.pages.models.Page.another_field", 73 | # "IntegerField", # 'django.db.models.' is implied if path is omitted. 74 | # (_("Another name"),), 75 | # {"blank": True, "default": 1}, 76 | # ), 77 | # ) 78 | 79 | # Setting to turn on featured images for blog posts. Defaults to False. 80 | # 81 | # BLOG_USE_FEATURED_IMAGE = True 82 | 83 | # If True, the django-modeltranslation will be added to the 84 | # INSTALLED_APPS setting. 85 | USE_MODELTRANSLATION = False 86 | 87 | 88 | ######################## 89 | # MAIN DJANGO SETTINGS # 90 | ######################## 91 | 92 | # Hosts/domain names that are valid for this site; required if DEBUG is False 93 | # See https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts 94 | ALLOWED_HOSTS = ['*'] 95 | 96 | # Local time zone for this installation. Choices can be found here: 97 | # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name 98 | # although not all choices may be available on all operating systems. 99 | # On Unix systems, a value of None will cause Django to use the same 100 | # timezone as the operating system. 101 | # If running in a Windows environment this must be set to the same as your 102 | # system time zone. 103 | TIME_ZONE = 'UTC' 104 | 105 | # If you set this to True, Django will use timezone-aware datetimes. 106 | USE_TZ = True 107 | 108 | # Language code for this installation. All choices can be found here: 109 | # http://www.i18nguy.com/unicode/language-identifiers.html 110 | LANGUAGE_CODE = "en" 111 | 112 | # Supported languages 113 | LANGUAGES = ( 114 | ('en', _('English')), 115 | ) 116 | 117 | # A boolean that turns on/off debug mode. When set to ``True``, stack traces 118 | # are displayed for error pages. Should always be set to ``False`` in 119 | # production. Best set to ``True`` in local_settings.py 120 | DEBUG = False 121 | 122 | # Whether a user's session cookie expires when the Web browser is closed. 123 | SESSION_EXPIRE_AT_BROWSER_CLOSE = True 124 | 125 | SITE_ID = 1 126 | 127 | # If you set this to False, Django will make some optimizations so as not 128 | # to load the internationalization machinery. 129 | USE_I18N = False 130 | 131 | AUTHENTICATION_BACKENDS = ("mezzanine.core.auth_backends.MezzanineBackend",) 132 | 133 | # The numeric mode to set newly-uploaded files to. The value should be 134 | # a mode you'd pass directly to os.chmod. 135 | FILE_UPLOAD_PERMISSIONS = 0o644 136 | 137 | ######### 138 | # PATHS # 139 | ######### 140 | 141 | # Full filesystem path to the project. 142 | PROJECT_APP_PATH = os.path.dirname(os.path.abspath(__file__)) 143 | PROJECT_APP = os.path.basename(PROJECT_APP_PATH) 144 | PROJECT_ROOT = BASE_DIR = os.path.dirname(PROJECT_APP_PATH) 145 | 146 | # Every cache key will get prefixed with this value - here we set it to 147 | # the name of the directory the project is in to try and use something 148 | # project specific. 149 | CACHE_MIDDLEWARE_KEY_PREFIX = PROJECT_APP 150 | 151 | # URL prefix for static files. 152 | # Example: "http://media.lawrence.com/static/" 153 | STATIC_URL = "/static/" 154 | 155 | # Absolute path to the directory static files should be collected to. 156 | # Don't put anything in this directory yourself; store your static files 157 | # in apps' "static/" subdirectories and in STATICFILES_DIRS. 158 | # Example: "/home/media/media.lawrence.com/static/" 159 | # STATIC_ROOT = os.path.join(PROJECT_ROOT, STATIC_URL.strip("/")) 160 | STATIC_ROOT = 'static' 161 | 162 | # URL that handles the media served from MEDIA_ROOT. Make sure to use a 163 | # trailing slash. 164 | # Examples: "http://media.lawrence.com/media/", "http://example.com/media/" 165 | MEDIA_URL = STATIC_URL + "media/" 166 | 167 | # Absolute filesystem path to the directory that will hold user-uploaded files. 168 | # Example: "/home/media/media.lawrence.com/media/" 169 | # MEDIA_ROOT = os.path.join(PROJECT_ROOT, MEDIA_URL.strip("/").split("/")) 170 | MEDIA_ROOT = 'static/media' 171 | 172 | # Package/module name to import the root urlpatterns from for the project. 173 | ROOT_URLCONF = "%s.urls" % PROJECT_APP 174 | 175 | TEMPLATES = [ 176 | { 177 | "BACKEND": "django.template.backends.django.DjangoTemplates", 178 | "DIRS": [ 179 | os.path.join(PROJECT_ROOT, "templates") 180 | ], 181 | "APP_DIRS": True, 182 | "OPTIONS": { 183 | "context_processors": [ 184 | "django.contrib.auth.context_processors.auth", 185 | "django.contrib.messages.context_processors.messages", 186 | "django.template.context_processors.debug", 187 | "django.template.context_processors.i18n", 188 | "django.template.context_processors.static", 189 | "django.template.context_processors.media", 190 | "django.template.context_processors.request", 191 | "django.template.context_processors.tz", 192 | "mezzanine.conf.context_processors.settings", 193 | "mezzanine.pages.context_processors.page", 194 | ], 195 | "builtins": [ 196 | "mezzanine.template.loader_tags", 197 | ], 198 | }, 199 | }, 200 | ] 201 | 202 | if DJANGO_VERSION < (1, 9): 203 | del TEMPLATES[0]["OPTIONS"]["builtins"] 204 | 205 | 206 | ################ 207 | # APPLICATIONS # 208 | ################ 209 | 210 | INSTALLED_APPS = ( 211 | 'mezzanine_api', 212 | 'rest_framework', 213 | 'rest_framework_swagger', 214 | 'oauth2_provider', 215 | "django.contrib.admin", 216 | "django.contrib.auth", 217 | "django.contrib.contenttypes", 218 | "django.contrib.redirects", 219 | "django.contrib.sessions", 220 | "django.contrib.sites", 221 | "django.contrib.sitemaps", 222 | "django.contrib.staticfiles", 223 | "mezzanine.boot", 224 | "mezzanine.conf", 225 | "mezzanine.core", 226 | "mezzanine.generic", 227 | "mezzanine.pages", 228 | "mezzanine.blog", 229 | "mezzanine.forms", 230 | "mezzanine.galleries", 231 | "mezzanine.twitter", 232 | # "mezzanine.accounts", 233 | # "mezzanine.mobile", 234 | ) 235 | 236 | # List of middleware classes to use. Order is important; in the request phase, 237 | # these middleware classes will be applied in the order given, and in the 238 | # response phase the middleware will be applied in reverse order. 239 | MIDDLEWARE_CLASSES = ( 240 | 'mezzanine_api.middleware.ApiMiddleware', 241 | 242 | "mezzanine.core.middleware.UpdateCacheMiddleware", 243 | 244 | 'django.contrib.sessions.middleware.SessionMiddleware', 245 | # Uncomment if using internationalisation or localisation 246 | # 'django.middleware.locale.LocaleMiddleware', 247 | 'django.middleware.common.CommonMiddleware', 248 | 'django.middleware.csrf.CsrfViewMiddleware', 249 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 250 | 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 251 | 'django.contrib.messages.middleware.MessageMiddleware', 252 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 253 | 254 | "mezzanine.core.request.CurrentRequestMiddleware", 255 | "mezzanine.core.middleware.RedirectFallbackMiddleware", 256 | "mezzanine.core.middleware.TemplateForDeviceMiddleware", 257 | "mezzanine.core.middleware.TemplateForHostMiddleware", 258 | "mezzanine.core.middleware.AdminLoginInterfaceSelectorMiddleware", 259 | "mezzanine.core.middleware.SitePermissionMiddleware", 260 | # Uncomment the following if using any of the SSL settings: 261 | # "mezzanine.core.middleware.SSLRedirectMiddleware", 262 | "mezzanine.pages.middleware.PageMiddleware", 263 | "mezzanine.core.middleware.FetchFromCacheMiddleware", 264 | ) 265 | 266 | # Store these package names here as they may change in the future since 267 | # at the moment we are using custom forks of them. 268 | PACKAGE_NAME_FILEBROWSER = "filebrowser_safe" 269 | PACKAGE_NAME_GRAPPELLI = "grappelli_safe" 270 | 271 | ######################### 272 | # OPTIONAL APPLICATIONS # 273 | ######################### 274 | 275 | # These will be added to ``INSTALLED_APPS``, only if available. 276 | OPTIONAL_APPS = ( 277 | "debug_toolbar", 278 | "django_extensions", 279 | "compressor", 280 | PACKAGE_NAME_FILEBROWSER, 281 | PACKAGE_NAME_GRAPPELLI, 282 | ) 283 | 284 | 285 | ################## 286 | # API SETTINGS # 287 | ################## 288 | 289 | # Load default settings for Mezzanine REST API 290 | # Use local_settings.py to customize API settings 291 | 292 | try: 293 | from mezzanine_api.settings import * # NOQA 294 | except ImportError: 295 | pass 296 | 297 | 298 | ################## 299 | # LOCAL SETTINGS # 300 | ################## 301 | 302 | # Allow any settings to be defined in local_settings.py which should be 303 | # ignored in your version control system allowing for settings to be 304 | # defined per machine. 305 | 306 | # Instead of doing "from .local_settings import *", we use exec so that 307 | # local_settings has full access to everything defined in this module. 308 | # Also force into sys.modules so it's visible to Django's autoreload. 309 | 310 | f = os.path.join(PROJECT_APP_PATH, "local_settings.py") 311 | if os.path.exists(f): 312 | import sys 313 | import imp 314 | module_name = "%s.local_settings" % PROJECT_APP 315 | module = imp.new_module(module_name) 316 | module.__file__ = f 317 | sys.modules[module_name] = module 318 | exec(open(f, "rb").read()) 319 | 320 | 321 | #################### 322 | # DYNAMIC SETTINGS # 323 | #################### 324 | 325 | # set_dynamic_settings() will rewrite globals based on what has been 326 | # defined so far, in order to provide some better defaults where 327 | # applicable. We also allow this settings module to be imported 328 | # without Mezzanine installed, as the case may be when using the 329 | # fabfile, where setting the dynamic settings below isn't strictly 330 | # required. 331 | try: 332 | from mezzanine.utils.conf import set_dynamic_settings 333 | except ImportError: 334 | pass 335 | else: 336 | set_dynamic_settings(globals()) 337 | -------------------------------------------------------------------------------- /web/docker_mezzanine/urls.py: -------------------------------------------------------------------------------- 1 | from __future__ import unicode_literals 2 | 3 | from django.conf.urls import include, url 4 | from django.conf.urls.i18n import i18n_patterns 5 | from django.contrib import admin 6 | from django.views.i18n import set_language 7 | 8 | from mezzanine.core.views import direct_to_template 9 | from mezzanine.conf import settings 10 | 11 | 12 | admin.autodiscover() 13 | 14 | # Add the urlpatterns for any custom Django applications here. 15 | # You can also change the ``home`` view to add your own functionality 16 | # to the project's homepage. 17 | 18 | urlpatterns = i18n_patterns( 19 | # Change the admin prefix here to use an alternate URL for the 20 | # admin interface, which would be marginally more secure. 21 | url("^admin/", include(admin.site.urls)), 22 | ) 23 | 24 | if settings.USE_MODELTRANSLATION: 25 | urlpatterns += [ 26 | url('^i18n/$', set_language, name='set_language'), 27 | ] 28 | 29 | urlpatterns += [ 30 | # REST API URLs 31 | url("^api/", include("mezzanine_api.urls")), 32 | 33 | # We don't want to presume how your homepage works, so here are a 34 | # few patterns you can use to set it up. 35 | 36 | # HOMEPAGE AS STATIC TEMPLATE 37 | # --------------------------- 38 | # This pattern simply loads the index.html template. It isn't 39 | # commented out like the others, so it's the default. You only need 40 | # one homepage pattern, so if you use a different one, comment this 41 | # one out. 42 | 43 | url("^$", direct_to_template, {"template": "index.html"}, name="home"), 44 | 45 | # HOMEPAGE AS AN EDITABLE PAGE IN THE PAGE TREE 46 | # --------------------------------------------- 47 | # This pattern gives us a normal ``Page`` object, so that your 48 | # homepage can be managed via the page tree in the admin. If you 49 | # use this pattern, you'll need to create a page in the page tree, 50 | # and specify its URL (in the Meta Data section) as "/", which 51 | # is the value used below in the ``{"slug": "/"}`` part. 52 | # Also note that the normal rule of adding a custom 53 | # template per page with the template name using the page's slug 54 | # doesn't apply here, since we can't have a template called 55 | # "/.html" - so for this case, the template "pages/index.html" 56 | # should be used if you want to customize the homepage's template. 57 | # NOTE: Don't forget to import the view function too! 58 | 59 | # url("^$", mezzanine.pages.views.page, {"slug": "/"}, name="home"), 60 | 61 | # HOMEPAGE FOR A BLOG-ONLY SITE 62 | # ----------------------------- 63 | # This pattern points the homepage to the blog post listing page, 64 | # and is useful for sites that are primarily blogs. If you use this 65 | # pattern, you'll also need to set BLOG_SLUG = "" in your 66 | # ``settings.py`` module, and delete the blog page object from the 67 | # page tree in the admin if it was installed. 68 | # NOTE: Don't forget to import the view function too! 69 | 70 | # url("^$", mezzanine.blog.views.blog_post_list, name="home"), 71 | 72 | # MEZZANINE'S URLS 73 | # ---------------- 74 | # ADD YOUR OWN URLPATTERNS *ABOVE* THE LINE BELOW. 75 | # ``mezzanine.urls`` INCLUDES A *CATCH ALL* PATTERN 76 | # FOR PAGES, SO URLPATTERNS ADDED BELOW ``mezzanine.urls`` 77 | # WILL NEVER BE MATCHED! 78 | 79 | # If you'd like more granular control over the patterns in 80 | # ``mezzanine.urls``, go right ahead and take the parts you want 81 | # from it, and use them directly below instead of using 82 | # ``mezzanine.urls``. 83 | url("^", include("mezzanine.urls")), 84 | 85 | # MOUNTING MEZZANINE UNDER A PREFIX 86 | # --------------------------------- 87 | # You can also mount all of Mezzanine's urlpatterns under a 88 | # URL prefix if desired. When doing this, you need to define the 89 | # ``SITE_PREFIX`` setting, which will contain the prefix. Eg: 90 | # SITE_PREFIX = "my/site/prefix" 91 | # For convenience, and to avoid repeating the prefix, use the 92 | # commented out pattern below (commenting out the one above of course) 93 | # which will make use of the ``SITE_PREFIX`` setting. Make sure to 94 | # add the import ``from django.conf import settings`` to the top 95 | # of this file as well. 96 | # Note that for any of the various homepage patterns above, you'll 97 | # need to use the ``SITE_PREFIX`` setting as well. 98 | 99 | # ("^%s/" % settings.SITE_PREFIX, include("mezzanine.urls")) 100 | 101 | ] 102 | 103 | # Adds ``STATIC_URL`` to the context of error pages, so that error 104 | # pages can use JS, CSS and images. 105 | handler404 = "mezzanine.core.views.page_not_found" 106 | handler500 = "mezzanine.core.views.server_error" 107 | -------------------------------------------------------------------------------- /web/docker_mezzanine/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for docker_mezzanine project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | from django.core.wsgi import get_wsgi_application 12 | 13 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "docker_mezzanine.settings") 14 | 15 | application = get_wsgi_application() 16 | -------------------------------------------------------------------------------- /web/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | 7 | from mezzanine.utils.conf import real_project_name 8 | 9 | settings_module = "%s.settings" % real_project_name("docker_mezzanine") 10 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", settings_module) 11 | 12 | from django.core.management import execute_from_command_line 13 | 14 | execute_from_command_line(sys.argv) 15 | -------------------------------------------------------------------------------- /web/requirements.txt: -------------------------------------------------------------------------------- 1 | mezzanine-api 2 | gunicorn==19.3.0 3 | psycopg2==2.6 4 | -------------------------------------------------------------------------------- /web/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Waiting for postgres container to be available" 4 | dockerize -wait tcp://postgres:5432 5 | 6 | echo "Mezzanine microservice executing: createdb/migrate ..." 7 | python3 manage.py createdb --noinput 8 | 9 | echo "Mezzanine microservice executing: collectstatic ..." 10 | python3 manage.py collectstatic --noinput 11 | 12 | echo "Starting WSGI ..." 13 | /usr/local/bin/gunicorn docker_mezzanine.wsgi:application -w 2 -b :8000 14 | -------------------------------------------------------------------------------- /web/templates/index.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% load i18n %} 3 | 4 | {% block meta_title %}{% trans "Home" %}{% endblock %} 5 | {% block title %}{% trans "Home" %}{% endblock %} 6 | 7 | {% block breadcrumb_menu %} 8 |
  • {% trans "Home" %}
  • 9 | {% endblock %} 10 | 11 | {% block main %} 12 | {% blocktrans %} 13 |

    Congratulations!

    14 |

    15 | Welcome to your new Mezzanine powered website. 16 | Here are some quick links to get you started with the API: 17 |

    18 | 26 |

    27 | Also, here are some general Mezzanine resources: 28 |

    29 | 37 | {% endblocktrans %} 38 | {% endblock %} --------------------------------------------------------------------------------