Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
thalia
concrexit
Commits
cedea272
Unverified
Commit
cedea272
authored
Sep 07, 2016
by
Thom Wiggers
📐
Browse files
Add docker image
parent
7046acf8
Changes
7
Hide whitespace changes
Inline
Side-by-side
Dockerfile
0 → 100644
View file @
cedea272
FROM
python:3.5-alpine
MAINTAINER
Thom Wiggers <thom@thomwiggers.nl>
LABEL
version=1.0
LABEL
description="Contains the Thaliawebsite Django application"
# Try to keep static operation on top to maximise Docker cache utilisation
# Disable output buffering
ENV
DJANGO_PRODUCTION 1
ENV
PYTHONUNBUFFERED 1
# Create log dir
RUN
mkdir
/log/
RUN
touch
/log/uwsgi.log
# Create app directory
RUN
mkdir
-p
/usr/src/app
# Create entry points
WORKDIR
/usr/local/bin
COPY
resources/entrypoint.sh /usr/local/bin/entrypoint.sh
COPY
resources/entrypoint_production.sh /usr/local/bin/entrypoint_production.sh
RUN
chmod
+x /usr/local/bin/entrypoint.sh
RUN
chmod
+x /usr/local/bin/entrypoint_production.sh
# Install dependencies
RUN
apk add
--no-cache
\
gettext
\
bash
\
postgresql-client
\
libwebp
\
tiff
\
zlib
\
freetype
\
uwsgi
\
lcms2
\
libjpeg-turbo
\
nodejs
# Install build deps
RUN
apk add
--no-cache
--virtual
.builddeps
\
build-base
\
tiff-dev
\
libjpeg-turbo-dev
\
zlib-dev
\
freetype-dev
\
lcms2-dev
\
libwebp-dev
\
postgresql-dev
WORKDIR
/usr/src/app
# install python requirements
COPY
requirements.txt /usr/src/app/
COPY
production-requirements.txt /usr/src/app/
RUN
pip
install
--no-cache-dir
\
-r
requirements.txt
\
-r
production-requirements.txt
# Install nodejs-less
RUN
npm
install
-g
less mkdirp
RUN
apk del .builddeps
# copy app source
COPY
website /usr/src/app/
ENTRYPOINT
["/usr/local/bin/entrypoint.sh"]
CMD
["--help"]
docker-compose.yml
0 → 100644
View file @
cedea272
version
:
'
2'
services
:
postgres
:
image
:
postgres
environment
:
&postgresvars
POSTGRES_DB
:
thalia
web
:
build
:
.
command
:
runserver 0.0.0.0:8000
ports
:
-
8000:8000
depends_on
:
-
postgres
volumes
:
-
./website:/usr/src/app
environment
:
<<
:
*postgresvars
DJANGO_DEBUG
:
'
True'
DJANGO_POSTGRES_HOST
:
postgres
production-requirements.txt
0 → 100644
View file @
cedea272
psycopg2
resources/entrypoint.sh
0 → 100755
View file @
cedea272
#!/bin/bash
set
-e
until
psql
-h
"
$DJANGO_POSTGRES_HOST
"
-U
"postgres"
-c
'\l'
;
do
>
&2
echo
"PostgreSQL is unavailable: Sleeping"
sleep
5
done
>
&2
echo
"PostgreSQL is up"
cd
/usr/src/app
>
&2
echo
"Running ./manage.py
$@
"
./manage.py
$@
resources/entrypoint_production.sh
0 → 100755
View file @
cedea272
#!/bin/bash
set
-e
until
psql
-h
"
$DJANGO_POSTGRES_HOST
"
-U
"postgres"
-c
'\l'
;
do
>
&2
echo
"PostgreSQL is unavailable: Sleeping"
sleep
5
done
>
&2
echo
"PostgreSQL is up"
cd
/usr/src/app
>
&2
echo
"Running site with uwsgi"
uwsgi
--chdir
/usr/src/app
\
--socket
:8000
\
--threads
2
\
--processes
4
\
--module
thaliawebsite.wsgi:application
\
--lazy-app
\
--harakiri
20
\
--max-requests
5000
\
--vacuum
\
--logto
'/log/uwsgi.log'
website/thaliawebsite/settings/__init__.py
View file @
cedea272
# flake8: noqa
import
os
from
.settings
import
*
try
:
from
.localsettings
import
*
except
ImportError
:
pass
if
os
.
environ
.
get
(
'DJANGO_PRODUCTION'
):
from
.production
import
*
website/thaliawebsite/settings/production.py
0 → 100644
View file @
cedea272
"""
Django settings for thaliawebsite project.
Docker version
"""
import
os
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY
=
os
.
environ
.
get
(
'DJANGO_SECRET'
,
'#o-0d1q5&^&06tn@8pr1f(n3$crafd++^%sacao7hj*ea@c)^t'
)
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG
=
os
.
environ
.
get
(
'DJANGO_DEBUG'
)
==
'True'
ALLOWED_HOSTS
=
os
.
environ
.
get
(
'DJANGO_HOSTS'
,
''
).
split
(
','
)
ROOT_URLCONF
=
'thaliawebsite.urls'
DATABASES
=
{
'default'
:
{
'ENGINE'
:
'django.db.backends.postgresql'
,
'NAME'
:
os
.
environ
.
get
(
'POSTGRES_USER'
),
'USER'
:
'postgres'
,
'DATABASE'
:
os
.
environ
.
get
(
'POSTGRES_DB'
),
'HOST'
:
os
.
environ
.
get
(
'DJANGO_POSTGRES_HOST'
),
'PORT'
:
5432
,
}
}
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/dev/howto/static-files/
# Where to store uploaded files
MEDIA_ROOT
=
os
.
path
.
join
(
'/'
,
'media'
)
MEDIA_URL
=
'/media/'
# Public is included by the db fields
SENDFILE_BACKEND
=
'sendfile.backends.development'
STATIC_URL
=
'/static/'
STATIC_ROOT
=
'/static'
COMPRESS_ENABLED
=
True
COMPRESS_PRECOMPILERS
=
(
(
'text/less'
,
'lessc {infile} {outfile}'
),
)
COMPRESS_CSS_FILTERS
=
[
'compressor.filters.css_default.CssAbsoluteFilter'
,
'compressor.filters.cssmin.rCSSMinFilter'
]
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment