Browse Source

init

tags/v1.0.0
Robin Thoni 7 years ago
commit
9e42cabc65
10 changed files with 195 additions and 0 deletions
  1. 43
    0
      backend/Dockerfile
  2. 60
    0
      backend/apache2.conf
  3. 1
    0
      backend/backend
  4. 41
    0
      backend/common.sh
  5. 8
    0
      backend/run.sh
  6. 1
    0
      backend/vars-files
  7. 1
    0
      backend/vars-vars
  8. 32
    0
      docker-compose.yml
  9. 1
    0
      env
  10. 7
    0
      update_vars.sh

+ 43
- 0
backend/Dockerfile View File

@@ -0,0 +1,43 @@
1
+FROM robinthoni/debian-multiarch:jessie
2
+
3
+# FROM https://github.com/ZHAJOR/Docker-Apache-2.4-Php-5.6-for-Laravel
4
+MAINTAINER Robin Thoni <robin@rthoni.com>
5
+
6
+ARG CONFIG_DIR=/etc/default/config-files/
7
+
8
+RUN apt-get update && apt-get -y install\
9
+        apache2=2.4.*\
10
+        libapache2-mod-php5\
11
+        php5\
12
+        php5-mcrypt\
13
+        php5-gd &&\
14
+        apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
15
+
16
+RUN /usr/sbin/a2enmod rewrite &&\
17
+    rm -rf /var/www/html &&\
18
+    mkdir -p /var/lock/apache2 /var/run/apache2 /var/log/apache2 /var/www/html &&\
19
+    chown -R www-data:www-data /var/lock/apache2 /var/run/apache2 /var/log/apache2 /var/www/html
20
+
21
+RUN rm -rf /var/log/* &&\
22
+    mkdir -p /var/log/apache2 &&\
23
+    ln -s /dev/stderr /var/log/apache2/error.log &&\
24
+    ln -s /dev/stdout /var/log/apache2/access.log &&\
25
+    ln -s /dev/stdout /var/log/apache2/other_vhosts_access.log
26
+
27
+COPY apache2.conf /etc/apache2/apache2.conf
28
+
29
+COPY ./backend/ /var/www/html/
30
+
31
+COPY ./vars-vars /etc/vars-vars
32
+
33
+COPY ./vars-files /etc/vars-files
34
+
35
+COPY ./common.sh /common.sh
36
+
37
+COPY ./run.sh /run.sh
38
+
39
+RUN mkdir "${CONFIG_DIR}"
40
+
41
+EXPOSE 80
42
+
43
+CMD ["/run.sh"]

+ 60
- 0
backend/apache2.conf View File

@@ -0,0 +1,60 @@
1
+# see http://sources.debian.net/src/apache2/2.4.10-1/debian/config-dir/apache2.conf
2
+
3
+ServerName backend
4
+Mutex file:/var/lock/apache2 default
5
+PidFile /var/run/apache2/apache2.pid
6
+Timeout 300
7
+KeepAlive On
8
+MaxKeepAliveRequests 100
9
+KeepAliveTimeout 5
10
+User www-data
11
+Group www-data
12
+HostnameLookups Off
13
+ErrorLog /var/log/apache2/error.log
14
+LogLevel warn
15
+
16
+IncludeOptional mods-enabled/*.load
17
+IncludeOptional mods-enabled/*.conf
18
+
19
+# ports.conf
20
+Listen 80
21
+<IfModule ssl_module>
22
+    Listen 443
23
+</IfModule>
24
+<IfModule mod_gnutls.c>
25
+    Listen 443
26
+</IfModule>
27
+
28
+DocumentRoot "/var/www/html/"
29
+
30
+<Directory />
31
+    Options FollowSymLinks
32
+    AllowOverride None
33
+    Require all denied
34
+</Directory>
35
+
36
+<Directory /var/www/html/>
37
+    Options FollowSymLinks
38
+    AllowOverride All
39
+    Require all granted
40
+</Directory>
41
+
42
+
43
+
44
+LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
45
+LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
46
+LogFormat "%h %l %u %t \"%r\" %>s %O" common
47
+LogFormat "%{Referer}i -> %U" referer
48
+LogFormat "%{User-agent}i" agent
49
+
50
+CustomLog /var/log/apache2/access.log combined
51
+
52
+<FilesMatch \.php$>
53
+    SetHandler application/x-httpd-php
54
+</FilesMatch>
55
+
56
+# Multiple DirectoryIndex directives within the same context will add
57
+# to the list of resources to look for rather than replace
58
+# https://httpd.apache.org/docs/current/mod/mod_dir.html#directoryindex
59
+DirectoryIndex disabled
60
+DirectoryIndex index.php index.html

+ 1
- 0
backend/backend

@@ -0,0 +1 @@
1
+Subproject commit 9b7a58d319483c6612a2d609978b9d5dc68458d4

+ 41
- 0
backend/common.sh View File

@@ -0,0 +1,41 @@
1
+export CONFIG_DIR="/etc/default/config-files/"
2
+
3
+resolv_host()
4
+{
5
+  hostname="${1}"
6
+  ip=$(getent hosts "${hostname}" | cut -d' ' -f1)
7
+  echo "${ip}"
8
+}
9
+
10
+replace_var()
11
+{
12
+  file="${1}"
13
+  var="${2}"
14
+  sed -e "s?${var}?${!var}?g" -i "${file}"
15
+}
16
+
17
+replace_vars()
18
+{
19
+  file="${1}"
20
+  for var in $(cat /etc/vars-vars)
21
+  do
22
+    replace_var "${file}" "${var}"
23
+  done
24
+}
25
+
26
+replace_files()
27
+{
28
+  cat /etc/vars-files | while read line
29
+  do
30
+    filesrc="${CONFIG_DIR}$(echo "${line}" | awk '{print $1}')"
31
+    filedst=$(echo "${line}" | awk '{print $2}')
32
+    if [ -f "${filesrc}" ]
33
+    then
34
+      echo "Expanding file ${filesrc} to ${filedst}"
35
+      cp "${filesrc}" "${filedst}"
36
+      replace_vars "${filedst}"
37
+    else
38
+      echo "File ${filesrc} does not exist. Skipping."
39
+    fi
40
+  done
41
+}

+ 8
- 0
backend/run.sh View File

@@ -0,0 +1,8 @@
1
+#! /usr/bin/env bash
2
+
3
+. /common.sh
4
+
5
+replace_files
6
+
7
+rm -f /run/apache2/apache2.pid
8
+exec /usr/sbin/apache2ctl -D FOREGROUND

+ 1
- 0
backend/vars-files View File

@@ -0,0 +1 @@
1
+/var/www/html/env

+ 1
- 0
backend/vars-vars View File

@@ -0,0 +1 @@
1
+CM_BACKEND_TOKEN

+ 32
- 0
docker-compose.yml View File

@@ -0,0 +1,32 @@
1
+version: '2'
2
+
3
+services:
4
+#    postgresql:
5
+#        build: ./postgresql
6
+#        container_name: pdns-postgresql
7
+#        networks:
8
+#            pdns.internal.docker:
9
+#                aliases:
10
+#                    - postgresql.pdns.internal.docker
11
+#        volumes:
12
+#            - ./data/postgresql/data:/var/lib/postgresql/data
13
+#            - ./data/postgresql/backup:/var/lib/postgresql/backup
14
+#        ports:
15
+#            - "127.0.0.1:35000:5432"
16
+#        env_file:
17
+#            - env
18
+
19
+    backend:
20
+        build: ./backend
21
+        container_name: backend-camotion
22
+        networks:
23
+            camotion.internal.docker:
24
+                aliases:
25
+                    - backend.camotion.internal.docker
26
+        ports:
27
+            - "127.0.0.1:35001:80"
28
+        env_file:
29
+            - env
30
+
31
+networks:
32
+    camotion.internal.docker:

+ 1
- 0
env View File

@@ -0,0 +1 @@
1
+CM_BACKEND_TOKEN=change_it

+ 7
- 0
update_vars.sh View File

@@ -0,0 +1,7 @@
1
+#! /usr/bin/env sh
2
+
3
+vars=$(cat env | cut -d= -f1)
4
+for docker in backend
5
+do
6
+  echo "${vars}" > "./${docker}/vars-vars"
7
+done

Loading…
Cancel
Save