Skip to content
This repository was archived by the owner on Nov 10, 2022. It is now read-only.

Commit bf4fd5d

Browse files
committed
Final fixups and improvements
1 parent c4fab37 commit bf4fd5d

File tree

4 files changed

+74
-17
lines changed

4 files changed

+74
-17
lines changed

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# A Docker EasyAppointments image
2+
3+
## Usage
4+
5+
Note: you need to login to ghcr.io using your GitHub account:
6+
7+
```sh
8+
docker login ghcr.io
9+
```
10+
11+
```yml
12+
version: "2.3"
13+
14+
services:
15+
easyappointments:
16+
image: ghcr.io/sudo-bot/docker-easyappointments/docker-easyappointments:latest
17+
environment:
18+
BASE_URL: http://easyappointments
19+
DB_HOST: mariadb.local
20+
DB_NAME: easyappointments
21+
DB_USERNAME: easyappointments
22+
DB_PASSWORD: easyappointments
23+
# DEBUG_MODE: true
24+
healthcheck:
25+
test:
26+
[
27+
"CMD",
28+
"curl",
29+
"-s",
30+
"--fail",
31+
"http://127.0.0.1/.nginx/status",
32+
]
33+
start_period: 5s
34+
interval: 15s
35+
timeout: 1s
36+
networks:
37+
# The network where mariadb.local resolves to an IP
38+
mynetwork:
39+
ports:
40+
- "127.0.0.36:80:80"
41+
```

docker/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ USER deploy:deploy
4545

4646
RUN curl -# -L -o easyappointments.zip ${DIST_URL} && \
4747
unzip -q easyappointments.zip && \
48-
rm easyappointments.zip
48+
rm easyappointments.zip && \
49+
echo -e '\n$config["uri_protocol"] = "REQUEST_URI";' >> application/config/config.php && \
50+
echo -e '\n$config["index_page"] = "";' >> application/config/config.php
4951

5052
# Metadata
5153
LABEL org.label-schema.vendor="Sudo-Bot" \

docker/config.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
$dbName = getenv('DB_NAME');
3030
$dbUsername = getenv('DB_USERNAME');
3131
$dbPassword = getenv('DB_PASSWORD');
32+
$debugMode = getenv('DEBUG_MODE') === 'true' ? 'true' : 'false';
3233

3334
$dataConfig = <<<PHP
3435
class Config {
@@ -39,7 +40,7 @@ class Config {
3940
4041
const BASE_URL = '$baseUrl';
4142
const LANGUAGE = 'french';
42-
const DEBUG_MODE = false;
43+
const DEBUG_MODE = $debugMode;
4344
4445
// ------------------------------------------------------------------------
4546
// DATABASE SETTINGS

docker/nginx-default.conf

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ server {
33
listen [::]:80 default_server;
44
server_tokens off;
55
autoindex off;
6+
index index.html index.php;
67

78
# https://alexanderallen.medium.com/forwarding-nginx-logs-to-docker-3bb6283a207
89
error_log stderr warn;
@@ -11,10 +12,6 @@ server {
1112
root /var/www/easyappointments;
1213
client_max_body_size 512M;
1314

14-
location / {
15-
index index.php;
16-
}
17-
1815
location /.nginx/status {
1916
stub_status;
2017
allow all;
@@ -30,20 +27,36 @@ server {
3027
return 200 "User-agent: *\nDisallow: /";
3128
}
3229

33-
location ~ \.php$ {
34-
fastcgi_pass unix:/run/phpfpm/php-fpm.sock;
35-
# regex to split $uri to $fastcgi_script_name and $fastcgi_path
36-
fastcgi_split_path_info ^(.+\.php)(/.+)$;
30+
# Deny for accessing codes
31+
location ~ ^/(application|system|vendor|engine|storage)/ {
32+
return 403;
33+
}
3734

38-
# Check that the PHP script exists before passing it
39-
try_files $fastcgi_script_name =404;
35+
# set expiration of assets to MAX for caching
36+
location ~ ^/(assets)/ {
37+
expires max;
38+
}
4039

41-
# Bypass the fact that try_files resets $fastcgi_path_info
42-
# see: https://trac.nginx.org/nginx/ticket/321
43-
set $path_info $fastcgi_path_info;
44-
fastcgi_param PATH_INFO $path_info;
40+
## Disable .htaccess and other hidden files
41+
location ~ /\. {
42+
deny all;
43+
access_log off;
44+
log_not_found off;
45+
}
4546

46-
fastcgi_index index.php;
47+
location / {
48+
# Check if a file or directory index file exists, else route it to index.php.
49+
try_files $uri $uri/ /index.php?/$request_uri;
50+
}
51+
52+
location ~* \.php$ {
53+
try_files $uri =404;
54+
fastcgi_pass unix:/run/phpfpm/php-fpm.sock;
4755
include fastcgi.conf;
56+
fastcgi_index index.php;
57+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
58+
fastcgi_param PATH_INFO $fastcgi_script_name;
59+
fastcgi_intercept_errors on;
4860
}
61+
4962
}

0 commit comments

Comments
 (0)