The docker-compose.yaml
version: '3.8'
networks:
proxy:
external: true
kcal:
driver: bridge
services:
app:
image: kcalapp/kcal
container_name: kcal-app
restart: unless-stopped
tty: true
working_dir: /app
env_file: .env
volumes:
- /home/zeus/kcal/data/:/app/public/
- /home/zeus/kcal/etc/php/php.ini:/usr/local/etc/php/conf.d/local.ini
networks:
- kcal
depends_on:
- db
web:
image: nginx:alpine
container_name: kcal-web
restart: unless-stopped
tty: true
privileged: true
env_file:
- .env
expose:
- "${APP_PORT:-80}"
- "${APP_PORT_SSL:-443}"
volumes:
- /home/zeus/kcal/data/:/app/public/
- /home/zeus/kcal/etc/nginx/conf.d/:/etc/nginx/conf.d/
networks:
- kcal
- proxy
labels:
- "traefik.enable=true"
- "traefik.http.routers.kcal.entrypoints=web"
- "traefik.http.routers.kcal.rule=Host(`recipes.lab.squeezeyourtime.com`)"
- "traefik.http.middlewares.kcal-https-redirect.redirectscheme.scheme=https"
- "traefik.http.routers.kcal.middlewares=kcal-https-redirect"
- "traefik.http.routers.kcal-secure.entrypoints=websecure"
- "traefik.http.routers.kcal-secure.rule=Host(`recipes.lab.squeezeyourtime.com`)"
- "traefik.http.routers.kcal-secure.tls=true"
- "traefik.http.routers.kcal-secure.service=kcal"
- "traefik.http.services.kcal.loadbalancer.server.port=${APP_PORT:-80}"
- "traefik.docker.network=proxy"
depends_on:
- app
db:
image: mysql:8.0
container_name: kcal-db
restart: unless-stopped
tty: true
expose:
- "${DB_PORT:-3306}"
env_file:
- .env
environment:
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD:-kcal}'
MYSQL_DATABASE: '${DB_DATABASE:-kcal}'
MYSQL_USER: '${DB_USERNAME:-kcal}'
MYSQL_PASSWORD: '${DB_PASSWORD:-kcal}'
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
volumes:
- /home/zeus/kcal/db/:/var/lib/mysql/
- /home/zeus/kcal/etc/mysql/my.cnf:/etc/mysql/my.cnf
networks:
- kcal
elasticsearch:
image: 'elasticsearch:7.12.0'
container_name: kcal-elasticsearch
env_file:
- .env
environment:
- xpack.security.enabled=false
- discovery.type=single-node
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
cap_add:
- IPC_LOCK
volumes:
- /home/zeus/kcal/elasticsearch:/usr/share/elasticsearch/data
expose:
- "${ELASTIC_PORT:-9200}"
networks:
- kcal
redis:
image: 'redis:alpine'
container_name: kcal-redis
env_file:
- .env
expose:
- "${REDIS_PORT:-6379}"
volumes:
- /home/zeus/kcal/redis:/data
networks:
- kcal
kcal-app logs:
[27-Sep-2022 11:22:49] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
[27-Sep-2022 11:22:49] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
[27-Sep-2022 11:22:49] NOTICE: fpm is running, pid 1
[27-Sep-2022 11:22:49] NOTICE: ready to handle connections
172.21.0.6 - 27/Sep/2022:11:23:36 +0000 "GET /index.php" 404
172.21.0.6 - 27/Sep/2022:11:23:37 +0000 "GET /index.php" 404
172.21.0.6 - 27/Sep/2022:11:23:37 +0000 "GET /index.php" 404
172.21.0.6 - 27/Sep/2022:11:23:37 +0000 "GET /index.php" 404
172.21.0.6 - 27/Sep/2022:11:23:37 +0000 "GET /index.php" 404
172.21.0.6 - 27/Sep/2022:11:23:38 +0000 "GET /index.php" 404
172.21.0.6 - 27/Sep/2022:11:23:38 +0000 "GET /index.php" 404
172.21.0.6 - 27/Sep/2022:11:23:38 +0000 "GET /index.php" 404
172.21.0.6 - 27/Sep/2022:11:29:38 +0000 "GET /index.php" 404
kcal-web logs:
2022/09/27 11:23:38 [error] 23#23: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 172.26.0.8, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://172.21.0.5:9000", host: "recipes.lab.squeezeyourtime.com", referrer: "https://recipes.lab.squeezeyourtime.com/"
172.26.0.8 - - [27/Sep/2022:11:23:38 +0000] "GET /favicon.ico HTTP/1.1" 404 27 "https://recipes.lab.squeezeyourtime.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:105.0) Gecko/20100101 Firefox/105.0"
.env:
#
# Kcal application configuration.
#
APP_NAME=kcal
APP_ENV=production
APP_KEY=long_random_string
APP_DEBUG=true
APP_URL=http://app
APP_PORT=80
APP_PORT_SSL=443
APP_TIMEZONE=Europe/Madrid
#
# Databases configuration.
#
DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=3306
DB_DATABASE=kcal
DB_USERNAME=kcal
DB_PASSWORD=strong_password
REDIS_HOST=redis
REDIS_PORT=6379
#
# Search configuration.
#
#SCOUT_DRIVER=null
#SCOUT_DRIVER=algolia
#ALGOLIA_APP_ID=
#ALGOLIA_SECRET=
SCOUT_DRIVER=elastic
ELASTIC_HOST=elasticsearch:9200
ELASTIC_PORT=9200
#
# Media (image storage) configuration.
#
MEDIA_DISK=media
QUEUE_CONVERSIONS_BY_DEFAULT=false
#MEDIA_DISK=s3-public
#AWS_ACCESS_KEY_ID=
#AWS_SECRET_ACCESS_KEY=
#AWS_DEFAULT_REGION=
#AWS_BUCKET=
#
# Misc. drivers and configuration.
#
BROADCAST_DRIVER=redis
CACHE_DRIVER=redis
QUEUE_CONNECTION=redis
SESSION_DRIVER=redis
SESSION_LIFETIME=120
nginx conf:
server {
listen 80;
root /app/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass app:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location ~ /\.(?!well-known).* {
deny all;
}
}

Portainer:

More info:
- I'm deploying the app with ansible
- I noticed that the local folder where the app is attached is empty. I guess I'm missing something.
The docker-compose.yaml
kcal-app logs:
kcal-web logs:
.env:
nginx conf:
Portainer:

More info: