nickjj / docker-flask-example

A production ready example Flask app that's using Docker and Docker Compose.
MIT License
583 stars 101 forks source link

Issues running in production executing the application #21

Closed webdz9r closed 3 months ago

webdz9r commented 3 months ago

my app works locally via docker no problem with the typical docker workflow.

I've moved it to my VM and attempting to build the app my requirements.txt file

Flask==3.0.2
werkzeug==3.0.1
jinja2==3.1.3
gunicorn==21.2.0

psycopg==3.1.18
SQLAlchemy==2.0.28
SQLAlchemy-Utils==0.41.1
Flask-SQLAlchemy==3.1.1
alembic==1.13.1

redis==5.0.3
celery==5.3.6

pytest==8.1.1
pytest-cov==4.1.0
flake8==7.0.0
isort==5.13.2
black==24.2.0

flask-debugtoolbar==0.14.1
Flask-Static-Digest==0.4.0
Flask-Secrets==0.1.0
Flask-DB==0.4.1

## mine added
pydantic
requests
pandas
datetime
ujson
lxml
beautifulsoup4
pyyaml
debugpy
gspread
python-dateutil
playwright

It's failing to build docker compose build with this message

 => [web app  9/11] COPY --chown=python:python --from=assets /app/public /public                                                                                                                                                     1.0s
 => [web app 10/11] COPY --chown=python:python . .                                                                                                                                                                                   0.9s
 => ERROR [web app 11/11] RUN if [ "false" != "true" ]; then   ln -s /public /app/public && flask digest compile && rm -rf /app/public; fi                                                                                           6.4s
------
 > [web app 11/11] RUN if [ "false" != "true" ]; then   ln -s /public /app/public && flask digest compile && rm -rf /app/public; fi:
5.582 Illegal instruction (core dumped)
------
failed to solve: process "/bin/sh -c if [ \"${FLASK_DEBUG}\" != \"true\" ]; then   ln -s /public /app/public && flask digest compile && rm -rf /app/public; fi" did not complete successfully: exit code: 132

in frustration I've cloned the repo in a different folder, added my same requirements.txt and without issue the hello flask builds and runs perfectly.

Any tips on tracking down what about my code / includes are causing the Illegal instruction (core dumped) I figured it was a python package. Everything I'm finding points to older CPU support, which if that was the case I'd expect the vanilla hello flask app not to build on the same host machine.

Thoughts? thanks in advance

webdz9r commented 3 months ago

Here is a log from trying to start web

[2024-04-06 20:40:20 +0000] [1] [INFO] Starting gunicorn 21.2.0
[2024-04-06 20:40:20 +0000] [1] [DEBUG] Arbiter booted
[2024-04-06 20:40:20 +0000] [1] [INFO] Listening at: http://0.0.0.0:8000 (1)
[2024-04-06 20:40:20 +0000] [1] [INFO] Using worker: sync
[2024-04-06 20:40:20 +0000] [8] [INFO] Booting worker with pid: 8
[2024-04-06 20:40:20 +0000] [1] [DEBUG] 1 workers
[2024-04-06 20:40:23 +0000] [1] [ERROR] Worker (pid:8) was sent code 132!
[2024-04-06 20:40:23 +0000] [12] [INFO] Booting worker with pid: 12
[2024-04-06 20:40:26 +0000] [1] [ERROR] Worker (pid:12) was sent code 132!
[2024-04-06 20:40:26 +0000] [16] [INFO] Booting worker with pid: 16
[2024-04-06 20:40:29 +0000] [1] [ERROR] Worker (pid:16) was sent code 132!
[2024-04-06 20:40:29 +0000] [20] [INFO] Booting worker with pid: 20
[2024-04-06 20:40:32 +0000] [1] [ERROR] Worker (pid:20) was sent code 132!
[2024-04-06 20:40:32 +0000] [24] [INFO] Booting worker with pid: 24
[2024-04-06 20:40:34 +0000] [1] [ERROR] Worker (pid:24) was sent code 132!
[2024-04-06 20:40:34 +0000] [28] [INFO] Booting worker with pid: 28
[2024-04-06 20:40:36 +0000] [1] [INFO] Handling signal: term
[2024-04-06 20:40:37 +0000] [1] [ERROR] Worker (pid:28) was sent code 132!
[2024-04-06 20:40:37 +0000] [1] [INFO] Shutting down: Master
[2024-04-06 20:40:46 +0000] [1] [DEBUG] Current configuration:
  config: python:config.gunicorn
  wsgi_app: None
  bind: ['0.0.0.0:8000']
  backlog: 2048
  workers: 1
  worker_class: sync
  threads: 1
  worker_connections: 1000
  max_requests: 0
  max_requests_jitter: 0
  timeout: 600
  graceful_timeout: 30
  keepalive: 2
  limit_request_line: 4094
  limit_request_fields: 100
  limit_request_field_size: 8190
  reload: True
  reload_engine: auto
  reload_extra_files: []
  spew: False
  check_config: False
  print_config: False
  preload_app: False
  sendfile: None
  reuse_port: False
  chdir: /app
  daemon: False
  raw_env: []
  pidfile: None
  worker_tmp_dir: None
  user: 1000
  group: 1000
  umask: 0
  initgroups: False
  tmp_upload_dir: None
  secure_scheme_headers: {'X-FORWARDED-PROTOCOL': 'ssl', 'X-FORWARDED-PROTO': 'https', 'X-FORWARDED-SSL': 'on'}
  forwarded_allow_ips: ['127.0.0.1']
  accesslog: -
  disable_redirect_access_to_syslog: False
  access_log_format: %(h)s %(l)s %(u)s %(t)s '%(r)s' %(s)s %(b)s '%(f)s' '%(a)s' in %(D)sµs
  errorlog: -
  loglevel: debug
  capture_output: False
  logger_class: gunicorn.glogging.Logger
  logconfig: None
  logconfig_dict: {}
  logconfig_json: None
  syslog_addr: udp://localhost:514
  syslog: False
  syslog_prefix: None
  syslog_facility: user
  enable_stdio_inheritance: False
  statsd_host: None
  dogstatsd_tags:
  statsd_prefix:
  proc_name: None
  default_proc_name: teetime.app:create_app()
  pythonpath: None
  paste: None
  on_starting: <function OnStarting.on_starting at 0x7fab245d0360>
  on_reload: <function OnReload.on_reload at 0x7fab245d04a0>
  when_ready: <function WhenReady.when_ready at 0x7fab245d05e0>
  pre_fork: <function Prefork.pre_fork at 0x7fab245d07c0>
  post_fork: <function Postfork.post_fork at 0x7fab245d0900>
  post_worker_init: <function PostWorkerInit.post_worker_init at 0x7fab245d0a40>
  worker_int: <function WorkerInt.worker_int at 0x7fab245d0b80>
  worker_abort: <function WorkerAbort.worker_abort at 0x7fab245d0cc0>
  pre_exec: <function PreExec.pre_exec at 0x7fab245d0e00>
  pre_request: <function PreRequest.pre_request at 0x7fab245d0f40>
  post_request: <function PostRequest.post_request at 0x7fab245d0fe0>
  child_exit: <function ChildExit.child_exit at 0x7fab245d1120>
  worker_exit: <function WorkerExit.worker_exit at 0x7fab245d1260>
  nworkers_changed: <function NumWorkersChanged.nworkers_changed at 0x7fab245d13a0>
  on_exit: <function OnExit.on_exit at 0x7fab245d14e0>
  ssl_context: <function NewSSLContext.ssl_context at 0x7fab245d16c0>
  proxy_protocol: False
  proxy_allow_ips: ['127.0.0.1']
  keyfile: None
  certfile: None
  ssl_version: 2
  cert_reqs: 0
  ca_certs: None
  suppress_ragged_eofs: True
  do_handshake_on_connect: False
  ciphers: None
  raw_paste_global_conf: []
  strip_header_spaces: False
[2024-04-06 20:40:46 +0000] [1] [INFO] Starting gunicorn 21.2.0
[2024-04-06 20:40:46 +0000] [1] [DEBUG] Arbiter booted
[2024-04-06 20:40:46 +0000] [1] [INFO] Listening at: http://0.0.0.0:8000 (1)
[2024-04-06 20:40:46 +0000] [1] [INFO] Using worker: sync
[2024-04-06 20:40:46 +0000] [8] [INFO] Booting worker with pid: 8
[2024-04-06 20:40:46 +0000] [1] [DEBUG] 1 workers
[2024-04-06 20:40:49 +0000] [1] [ERROR] Worker (pid:8) was sent code 132!
[2024-04-06 20:40:49 +0000] [12] [INFO] Booting worker with pid: 12
[2024-04-06 20:40:52 +0000] [1] [ERROR] Worker (pid:12) was sent code 132!
[2024-04-06 20:40:52 +0000] [16] [INFO] Booting worker with pid: 16
[2024-04-06 20:40:55 +0000] [1] [ERROR] Worker (pid:16) was sent code 132!
[2024-04-06 20:40:55 +0000] [20] [INFO] Booting worker with pid: 20
[2024-04-06 20:40:57 +0000] [1] [ERROR] Worker (pid:20) was sent code 132!
[2024-04-06 20:40:57 +0000] [24] [INFO] Booting worker with pid: 24
webdz9r commented 3 months ago

whelp it seems it's on my side from my blueprint I've imported - not sure why it works on some machines and not others

webdz9r commented 3 months ago

for those playing along it was a temp folder missing from version control which was needed for some backed in caching solution. eff me that sucked to troubleshoot

nickjj commented 3 months ago

Hi,

Thanks for letting us know what it was in the end.