Browse Source

Thirst test version of Dockerfile (working)

Bastien Sevajol (Algoo) 8 years ago
parent
commit
c45d2c7858

+ 48 - 0
Docker/Debian_Uwsgi_PostgreSQL/Dockerfile View File

@@ -0,0 +1,48 @@
1
+FROM debian:jessie
2
+MAINTAINER contact@algoo.fr
3
+
4
+# TODO: See GOOD PRATICE (remove apt lists, etc)
5
+
6
+# Install required packages
7
+RUN apt-get update -q \
8
+    && DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
9
+      git \
10
+      locales \
11
+      realpath \
12
+      python3 \
13
+      python3-dev \
14
+      python3-pip \
15
+      build-essential \
16
+      libxml2-dev \
17
+      libxslt1-dev \
18
+      python-lxml \
19
+      postgresql-server-dev-all \
20
+      postgresql \
21
+      postgresql-client \
22
+      uwsgi \
23
+      uwsgi-plugin-python3
24
+
25
+# Ensure UTF-8
26
+RUN locale-gen en_US.UTF-8 en_us \
27
+    && dpkg-reconfigure locales \
28
+    && dpkg-reconfigure locales \
29
+    && locale-gen C.UTF-8 \
30
+    && /usr/sbin/update-locale LANG=C.UTF-8
31
+ENV LANG C.UTF-8
32
+ENV LANGUAGE C.UTF-8
33
+ENV LC_ALL C.UTF-8
34
+
35
+# Download and install Tracim
36
+RUN git clone https://github.com/tracim/tracim.git \
37
+     && cd /tracim/tracim \
38
+     && python3 setup.py develop \
39
+     && cd /tracim \
40
+     && pip3 install -r install/requirements.txt
41
+
42
+# Copy needed files
43
+COPY uwsgi.ini /etc/uwsgi/apps-available/tracim.ini
44
+COPY wsgi.py /tracim/tracim/wsgi.py
45
+COPY entrypoint.sh /tracim/entrypoint.sh
46
+
47
+# Set the default entry point
48
+CMD ["/tracim/entrypoint.sh"]

+ 4 - 0
Docker/Debian_Uwsgi_PostgreSQL/default_locale View File

@@ -0,0 +1,4 @@
1
+LC_ALL=en_US.UTF8
2
+LANG=en_US.UTF8
3
+LC_CTYPE=en_US.UTF8
4
+LC_COLLATE=en_US.UTF8

+ 32 - 0
Docker/Debian_Uwsgi_PostgreSQL/entrypoint.sh View File

@@ -0,0 +1,32 @@
1
+#!/usr/bin/env bash
2
+
3
+# TODO: Données de postgreSQL dans un volume
4
+# TODO: Mettre des variable d'environn pour la config
5
+# TODO: Supporter le changement des variables d'environnement ? (actuellement utilisé pour générer le .ini)
6
+# TODO: Fichiers de config link ls -s dans un dossier pour VOLUME
7
+# TODO: README QQCH pour les ports ? 80, 3060 et 5333
8
+
9
+# Start PostgreSQL
10
+service postgresql start
11
+
12
+# Init database if needed
13
+if ! [ "$( su - postgres -s /bin/bash -c "psql -tAc \"SELECT 1 FROM pg_database WHERE datname='tracim'\"" )" = '1' ]; then
14
+    su - postgres -s /bin/bash -c "psql -c \"CREATE DATABASE tracim;\""
15
+    su - postgres -s /bin/bash -c "psql -c \"CREATE USER tracim WITH PASSWORD 'tracim';\""
16
+    su - postgres -s /bin/bash -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE tracim TO tracim;\""
17
+fi
18
+
19
+# Create config.ini file if no exist
20
+if [ ! -f /tracim/tracim/config.ini ]; then
21
+    cp /tracim/tracim/development.ini.base /tracim/tracim/config.ini
22
+    sed -i "s/\(sqlalchemy.url *= *\).*/\1postgresql:\/\/tracim:tracim@127.0.0.1:5432\/tracim?client_encoding=utf8/" /tracim/tracim/config.ini
23
+    # TODO: ENV VAR
24
+fi
25
+
26
+# Create wsgidav.conf file if no exist
27
+if [ ! -f /tracim/tracim/wsgidav.conf ]; then
28
+    cp /tracim/tracim/wsgidav.conf.sample /tracim/tracim/wsgidav.conf
29
+fi
30
+
31
+# Start with uwsgi
32
+uwsgi --http-socket 0.0.0.0:80 /etc/uwsgi/apps-available/tracim.ini

+ 6 - 0
Docker/Debian_Uwsgi_PostgreSQL/uwsgi.ini View File

@@ -0,0 +1,6 @@
1
+[uwsgi]
2
+plugins = python3
3
+chdir = /tracim/tracim
4
+module = wsgi
5
+callable = application
6
+enable-threads = true

+ 5 - 0
Docker/Debian_Uwsgi_PostgreSQL/wsgi.py View File

@@ -0,0 +1,5 @@
1
+# -*- coding: utf-8 -*-
2
+from paste.deploy import loadapp
3
+
4
+application = loadapp('config:/tracim/tracim/config.ini')
5
+application.debug = False