Browse Source

Initial commit, seems to work

Christoph Haas 4 months ago
parent
commit
401d070778
7 changed files with 179 additions and 0 deletions
  1. 57
    0
      .env.sample
  2. 2
    0
      .gitignore
  3. 49
    0
      docker-compose.yml
  4. 3
    0
      docker/php/Dockerfile
  5. 3
    0
      nginx/conf.d/default.conf
  6. 32
    0
      nginx/nginx.conf
  7. 33
    0
      nginx/sites/default.conf

+ 57
- 0
.env.sample View File

@@ -0,0 +1,57 @@
1
+# .env file to set up your LEMP stack with letsencrypt
2
+
3
+#
4
+# Network name
5
+# 
6
+# Your container app must use a network conencted to your webproxy 
7
+# https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion
8
+#
9
+NETWORK=webproxy
10
+
11
+
12
+#
13
+# Database Container configuration
14
+# We recommend MySQL or MariaDB - please update docker-compose file if needed.
15
+#
16
+CONTAINER_DB_NAME=db
17
+
18
+# Path to store your database
19
+#DB_PATH=/path/to/your/local/database/folder
20
+DB_PATH=./data/db
21
+
22
+# Root password for your database
23
+MYSQL_ROOT_PASSWORD=root_password
24
+
25
+# Database name, user and password for your wordpress
26
+MYSQL_DATABASE=database_name
27
+MYSQL_USER=user_name
28
+MYSQL_PASSWORD=user_password
29
+
30
+
31
+#
32
+# PHP Settings
33
+#
34
+CONTAINER_PHP_NAME=php
35
+
36
+
37
+#
38
+# Webroot configuration
39
+#
40
+#WEBROOT_PATH=/path/to/your/webroot
41
+WEBROOT_PATH=./data/www
42
+
43
+
44
+#
45
+# NGINX Settings
46
+#
47
+CONTAINER_NGINX_NAME=nginx
48
+NGINX_PORT=8081
49
+
50
+#
51
+# Host
52
+#
53
+# Your domain (or domains) 
54
+VIRTUAL_HOST=domain1.com,www.domain1.com
55
+LETSENCRYPT_HOST=domain1.com,www.domain1.com
56
+# Your email for Let's Encrypt register
57
+LETSENCRYPT_EMAIL=your_email@domain.com

+ 2
- 0
.gitignore View File

@@ -5,3 +5,5 @@
5 5
 !.vscode/launch.json
6 6
 !.vscode/extensions.json
7 7
 
8
+# ---> Production Config File
9
+.env

+ 49
- 0
docker-compose.yml View File

@@ -0,0 +1,49 @@
1
+version: '3'
2
+
3
+services:
4
+    db:
5
+        container_name: ${CONTAINER_DB_NAME}
6
+        image: mariadb:latest
7
+        restart: unless-stopped
8
+        volumes:
9
+            - ${DB_PATH}:/var/lib/mysql
10
+        environment:
11
+            MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
12
+            MYSQL_DATABASE: ${MYSQL_DATABASE}
13
+            MYSQL_USER: ${MYSQL_USER}
14
+            MYSQL_PASSWORD: ${MYSQL_PASSWORD}
15
+    
16
+    php-fpm:
17
+        container_name: ${CONTAINER_PHP_NAME}
18
+        #image: php:7-fpm
19
+        build: docker/php
20
+        restart: unless-stopped
21
+        volumes:
22
+            - ${WEBROOT_PATH}:/var/www
23
+        links:
24
+            - db
25
+
26
+    nginx:
27
+        container_name: ${CONTAINER_NGINX_NAME}
28
+        image: nginx:stable
29
+        volumes:
30
+            - ${WEBROOT_PATH}:/var/www
31
+            - ./nginx/nginx.conf:/etc/nginx/nginx.conf
32
+            - ./nginx/sites/:/etc/nginx/sites-enabled
33
+            - ./nginx/conf.d/:/etc/nginx/conf.d
34
+        depends_on:
35
+            - php-fpm
36
+        ports:
37
+            - "${NGINX_PORT}:80"
38
+        links:
39
+            - php-fpm
40
+
41
+        environment:
42
+           VIRTUAL_HOST: ${VIRTUAL_HOST}
43
+           LETSENCRYPT_HOST: ${LETSENCRYPT_HOST}
44
+           LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL}
45
+
46
+networks:
47
+    default:
48
+       external:
49
+         name: ${NETWORK}

+ 3
- 0
docker/php/Dockerfile View File

@@ -0,0 +1,3 @@
1
+FROM php:7-fpm
2
+
3
+RUN docker-php-ext-install pdo_mysql

+ 3
- 0
nginx/conf.d/default.conf View File

@@ -0,0 +1,3 @@
1
+upstream php-upstream {
2
+    server php-fpm:9000;
3
+}

+ 32
- 0
nginx/nginx.conf View File

@@ -0,0 +1,32 @@
1
+user  nginx;
2
+worker_processes  4;
3
+
4
+error_log  /var/log/nginx/error.log warn;
5
+pid        /var/run/nginx.pid;
6
+
7
+
8
+events {
9
+    worker_connections  1024;
10
+}
11
+
12
+
13
+http {
14
+    include       /etc/nginx/mime.types;
15
+    default_type  application/octet-stream;
16
+
17
+    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
18
+                      '$status $body_bytes_sent "$http_referer" '
19
+                      '"$http_user_agent" "$http_x_forwarded_for"';
20
+
21
+    access_log  /var/log/nginx/access.log  main;
22
+
23
+    sendfile        on;
24
+    #tcp_nopush     on;
25
+
26
+    keepalive_timeout  65;
27
+
28
+    #gzip  on;
29
+
30
+    include /etc/nginx/conf.d/*.conf;
31
+    include /etc/nginx/sites-enabled/*.conf;
32
+}

+ 33
- 0
nginx/sites/default.conf View File

@@ -0,0 +1,33 @@
1
+server {
2
+    listen 80 default_server;
3
+    listen [::]:80 default_server;
4
+
5
+    server_name localhost;
6
+    root /var/www;
7
+    index index.php index.html index.htm;
8
+
9
+    location / {
10
+         try_files $uri $uri/ /index.php$is_args$args;
11
+    }
12
+
13
+    location ~ \.php$ {
14
+        try_files $uri /index.php =404;
15
+        fastcgi_pass php-upstream;
16
+        fastcgi_index index.php;
17
+        fastcgi_buffers 16 16k;
18
+        fastcgi_buffer_size 32k;
19
+        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
20
+        #fixes timeouts
21
+        fastcgi_read_timeout 600;
22
+        include fastcgi_params;
23
+    }
24
+
25
+    location ~ /\.ht {
26
+        deny all;
27
+    }
28
+
29
+    location /.well-known/acme-challenge/ {
30
+        root /var/www/letsencrypt/;
31
+        log_not_found off;
32
+    }
33
+}

Loading…
Cancel
Save