Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to launch the app #2

Open
raducostinas opened this issue Sep 27, 2022 · 2 comments
Open

Unable to launch the app #2

raducostinas opened this issue Sep 27, 2022 · 2 comments

Comments

@raducostinas
Copy link

raducostinas commented Sep 27, 2022

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;
    }
}

imagen

Portainer:
imagen

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.
@T012m3n7oR
Copy link

T012m3n7oR commented Jun 12, 2023

Problem: The /app/public directory is empty
Possible Workaround Steps:

  1. Do not map /app/public on first load of the kcal-app container. Map a different directory that won't interfere. This will be remapped after. (I used /opt/kcal/data:/kcal-data)
  2. run docker-compose exec app cp /app/public/ /kcal-data
  3. stop the app container, confirm that the volume/host mapped path has the intended files.
  4. remap /opt/kcal/data:/app/public
  5. start the container.

This allowed me to take the /app/public directory that existed in the container before the host mapped drive replaced it.

If you use a reverse proxy that forces SSL/TLS you will encounter this issue: kcal-app/kcal#54 however there is a workaround for that as well.

@deggle
Copy link

deggle commented Oct 11, 2023

Had the same issue, and the steps above did help - though I assume I'll have to re-do this whenever there is an update? It's a bit of a pain, not sure why this can't be implemented in a way that works better as it's the first time I've had to deal with an issue like this with a docker project.

Anyway, I get a login page now, but on logging in (with any credentials) I just get a 500 error - does anyone have any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants