Browse Source

working version

tags/v0.1.0
Robin Thoni 7 years ago
parent
commit
f41f8d336b

+ 2
- 0
.gitignore View File

@@ -1,2 +1,4 @@
1 1
 *.swp
2 2
 /data
3
+/backend/backend
4
+/frontend/frontend

+ 26
- 0
backend/Dockerfile View File

@@ -0,0 +1,26 @@
1
+FROM microsoft/dotnet:latest
2
+
3
+RUN rm -rf /var/log/*
4
+
5
+COPY ./backend/ /tmp/backend/
6
+
7
+ENV WEBAPI_PROJECT WebTest
8
+ENV BUILD_CONFIG Release
9
+
10
+RUN cd /tmp/backend && \
11
+    dotnet restore && \
12
+    find . -name project.json | xargs dotnet build -c ${BUILD_CONFIG} && \
13
+    mkdir /var/www && \
14
+    cd /tmp/backend/${WEBAPI_PROJECT} && \
15
+    dotnet publish --output /var/www && \
16
+    ln -s /var/www/${WEBAPI_PROJECT}.dll /var/www/__RUN_ME.DLL
17
+
18
+COPY ./vars-vars /etc/vars-vars
19
+
20
+COPY ./vars-files /etc/vars-files
21
+
22
+COPY ./run.sh /run.sh
23
+
24
+EXPOSE 80
25
+
26
+CMD ["/run.sh"]

+ 30
- 0
backend/run.sh View File

@@ -0,0 +1,30 @@
1
+#! /usr/bin/env bash
2
+
3
+replace_var()
4
+{
5
+  file="${1}"
6
+  var="${2}"
7
+  sed -e "s?${var}?${!var}?g" -i "${file}"
8
+}
9
+
10
+replace_vars()
11
+{
12
+  file="${1}"
13
+  for var in $(cat /etc/vars-vars)
14
+  do
15
+    replace_var "${file}" "${var}"
16
+  done
17
+}
18
+
19
+replace_files()
20
+{
21
+  for file in $(cat /etc/vars-files)
22
+  do
23
+    replace_vars "${file}"
24
+  done
25
+}
26
+
27
+replace_files
28
+
29
+cd /var/www &&
30
+dotnet __RUN_ME.DLL

+ 0
- 0
backend/vars-files View File


+ 7
- 0
backend/vars-vars View File

@@ -0,0 +1,7 @@
1
+POSTGRES_HOST
2
+POSTGRES_USER
3
+POSTGRES_PASSWORD
4
+POSTGRES_DB
5
+
6
+BACKEND_HOST
7
+BACKEND_PORT

+ 42
- 0
docker-compose.yml View File

@@ -0,0 +1,42 @@
1
+version: '2'
2
+
3
+services:
4
+    postgresql:
5
+        build: ./postgresql
6
+        container_name: project-luticate2-postgresql
7
+        networks:
8
+            project.internal.docker:
9
+                aliases:
10
+                    - postgresql.project.internal.docker
11
+        volumes:
12
+            - ./data/postgresql/data:/var/lib/postgresql/data
13
+        ports:
14
+            - "127.0.0.1:34030:5432"
15
+        env_file:
16
+            - env
17
+
18
+    frontend:
19
+        build: ./frontend
20
+        container_name: project-luticate2-frontend
21
+        networks:
22
+            project.internal.docker:
23
+                aliases:
24
+                    - frontend.project.internal.docker
25
+        ports:
26
+            - "127.0.0.1:34031:80"
27
+        env_file:
28
+            - env
29
+
30
+    backend:
31
+        build: ./backend
32
+        container_name: project-luticate2-backend
33
+        networks:
34
+            project.internal.docker:
35
+                aliases:
36
+                    - backend.project.internal.docker
37
+        env_file:
38
+            - env
39
+
40
+
41
+networks:
42
+    project.internal.docker:

+ 8
- 0
env View File

@@ -0,0 +1,8 @@
1
+POSTGRES_HOST=postgresql.project.internal.docker
2
+POSTGRES_USER=poweradmin
3
+POSTGRES_PASSWORD=pg_password
4
+POSTGRES_DB=poweradmin
5
+
6
+BACKEND_HOST=backend.project.internal.docker
7
+BACKEND_PORT=8080
8
+

+ 43
- 0
frontend/Dockerfile View File

@@ -0,0 +1,43 @@
1
+FROM debian: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
+RUN apt-get update && apt-get -y install\
7
+        apache2=2.4.*\
8
+        libapache2-mod-php5\
9
+        php5\
10
+        php5-mcrypt\
11
+        php5-pgsql\
12
+        php5-mysql\
13
+        php5-gd\
14
+        php5-curl\
15
+        php5-imap &&\
16
+        apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
17
+
18
+RUN /usr/sbin/a2enmod rewrite &&\
19
+    rm -rf /var/www/html &&\
20
+    mkdir -p /var/lock/apache2 /var/run/apache2 /var/log/apache2 /var/www/html &&\
21
+    chown -R www-data:www-data /var/lock/apache2 /var/run/apache2 /var/log/apache2 /var/www/html
22
+
23
+RUN rm -rf /var/log/* &&\
24
+    mkdir -p /var/log/apache2 &&\
25
+    ln -s /dev/stderr /var/log/apache2/error.log &&\
26
+    ln -s /dev/stdout /var/log/apache2/access.log &&\
27
+    ln -s /dev/stdout /var/log/apache2/other_vhosts_access.log
28
+
29
+RUN a2enmod proxy_http
30
+
31
+COPY apache2.conf /etc/apache2/apache2.conf
32
+
33
+COPY ./frontend/ /var/www/html/
34
+
35
+COPY ./vars-vars /etc/vars-vars
36
+
37
+COPY ./vars-files /etc/vars-files
38
+
39
+COPY ./run.sh /run.sh
40
+
41
+EXPOSE 80
42
+
43
+CMD ["/run.sh"]

+ 63
- 0
frontend/apache2.conf View File

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

+ 30
- 0
frontend/run.sh View File

@@ -0,0 +1,30 @@
1
+#! /usr/bin/env bash
2
+
3
+replace_var()
4
+{
5
+  file="${1}"
6
+  var="${2}"
7
+  sed -e "s?${var}?${!var}?g" -i "${file}"
8
+}
9
+
10
+replace_vars()
11
+{
12
+  file="${1}"
13
+  for var in $(cat /etc/vars-vars)
14
+  do
15
+    replace_var "${file}" "${var}"
16
+  done
17
+}
18
+
19
+replace_files()
20
+{
21
+  for file in $(cat /etc/vars-files)
22
+  do
23
+    replace_vars "${file}"
24
+  done
25
+}
26
+
27
+replace_files
28
+
29
+rm -f /run/apache2/apache2.pid
30
+exec /usr/sbin/apache2ctl -D FOREGROUND

+ 1
- 0
frontend/vars-files View File

@@ -0,0 +1 @@
1
+/etc/apache2/apache2.conf

+ 7
- 0
frontend/vars-vars View File

@@ -0,0 +1,7 @@
1
+POSTGRES_HOST
2
+POSTGRES_USER
3
+POSTGRES_PASSWORD
4
+POSTGRES_DB
5
+
6
+BACKEND_HOST
7
+BACKEND_PORT

+ 5
- 0
postgresql/Dockerfile View File

@@ -0,0 +1,5 @@
1
+FROM postgres:9.6
2
+
3
+RUN rm -rf /var/log/*
4
+
5
+COPY ./docker-entrypoint-initdb.d/ /docker-entrypoint-initdb.d

+ 0
- 0
postgresql/docker-entrypoint-initdb.d/01_init.sql View File


+ 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 frontend backend
5
+do
6
+  echo "${vars}" > "./${docker}/vars-vars"
7
+done

Loading…
Cancel
Save