walysonmaxwel / ligo-clientes

0 stars 0 forks source link

flask_crud_clientes: no such file or directory #2

Closed mensageirodobem closed 1 month ago

mensageirodobem commented 1 month ago

Foi realizado o build do docker-compose com sucesso. Abaixo o log.

Porém, o container flask_crud_clientes foi finalizado com erro, com o seguinte log: exec /app/entrypoint.sh: no such file or directory

Estou usando o Docker 4.30.0 em um Windows 11 com WSL Ubuntu 22.04 LTS

Executing task: docker compose -f "docker-compose.yml" up -d --build

[+] Running 15/1 ✔ db Pulled 29.9s [+] Building 0.0s (0/0) docker:default [+] Building 36.2s (21/21) FINISHED docker:default => [flask_crud_clientes internal] load build definition from Dockerfile 0.1s => => transferring dockerfile: 633B 0.0s => [fastapi_jwt internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 411B 0.0s => [flask_crud_clientes internal] load metadata for docker.io/library/python:3.9-slim 3.1s => [flask_crud_clientes auth] library/python:pull token for registry-1.docker.io 0.0s => [fastapi_jwt internal] load .dockerignore 5.4s => => transferring context: 2B 0.0s => [flask_crud_clientes internal] load .dockerignore 3.4s => => transferring context: 2B 0.0s => [fastapi_jwt 1/7] FROM docker.io/library/python:3.9-slim@sha256:e9074b2ea84e00d4a73a7d0c01c52820e7b68d8901c5fa282be4f1b289d5b55 0.0s => [flask_crud_clientes internal] load build context 23.0s => => transferring context: 1.58kB 0.0s => [fastapi_jwt internal] load build context 23.2s => => transferring context: 637B 0.0s => CACHED [fastapi_jwt 2/7] WORKDIR /app 0.0s => CACHED [flask_crud_clientes 3/7] RUN apt-get update && apt-get install -y build-essential libpq-dev gcc netcat- 0.0s => CACHED [flask_crud_clientes 4/7] COPY requirements.txt requirements.txt 0.0s => CACHED [flask_crud_clientes 5/7] RUN pip install -r requirements.txt 0.0s => [flask_crud_clientes 6/7] COPY . /app 1.9s => CACHED [fastapi_jwt 3/6] RUN apt-get update && apt-get install -y build-essential libpq-dev gcc && rm -rf /var/ 0.0s => CACHED [fastapi_jwt 4/6] COPY requirements.txt requirements.txt 0.0s => CACHED [fastapi_jwt 5/6] RUN pip install -r requirements.txt 0.0s => CACHED [fastapi_jwt 6/6] COPY . /app/src 0.0s => [fastapi_jwt] exporting to image 0.9s => => exporting layers 0.0s => => writing image sha256:8d8f2d23e674be4b8087576d35429ea42a680dd62fb81f464710ab64d09812f2 0.2s => => naming to docker.io/library/ligo-clientes-fastapi_jwt 0.4s => [flask_crud_clientes 7/7] RUN chmod +x entrypoint.sh 1.4s => [flask_crud_clientes] exporting to image 0.3s => => exporting layers 0.2s => => writing image sha256:33a3ae6afebf39950154f3337badf8d7200a68114e84b38018962eefb35df8c3 0.0s => => naming to docker.io/library/ligo-clientes-flask_crud_clientes 0.0s [+] Running 4/4 ✔ Network ligo-clientes_clientes_net Created 0.1s ✔ Container postgres_db Started 2.3s ✔ Container flask_crud_clientes Started 2.8s ✔ Container fastapi_jwt Started 2.8s

walysonmaxwel commented 1 month ago

Não consegui reproduzir o erro descrito. Sugiro:

  1. atualizar a versão do docker/docker compose.

Testes realizados com as seguintes versões docker --version Docker version 25.0.0, build e758fe5

docker compose version Docker Compose version v2.24.1

wsl --version WSL version: 2.1.5.0

lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04.3 LTS Release: 22.04 Codename: jammy

  1. Realizar o clone do projeto direatamente dentro do wsl uma vez que clonar o projeto dentro do diretório de arquivos do windows seguido pela subida de container de dentro do wsl pode causar alguns problemas relacionados ao CRLF. Segue referência: crlf

  2. Os testes foram feitos utilizando o docker engine diretamente de dentro do wsl e não a versão gui do docker desktop para windows

Segue output de compilação obtido

docker compose up --build [+] Running 15/15 ✔ db 14 layers [⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿] 0B/0B Pulled 22.3s ✔ 2cc3ae149d28 Pull complete 4.1s ✔ e6fd2e12bb17 Pull complete 0.9s ✔ 31b1d7acb36a Pull complete 2.9s ✔ daed6e01d2bd Pull complete 3.0s ✔ bef99882b45e Pull complete 4.8s ✔ 23ba358eeb18 Pull complete 4.7s ✔ e026dced26a8 Pull complete 4.9s ✔ dfddffae2362 Pull complete 5.4s ✔ 93d519ce0602 Pull complete 13.3s ✔ ca1bdcd4df86 Pull complete 5.7s ✔ 19ecff9742eb Pull complete 6.3s ✔ c24ce334bc29 Pull complete 6.8s ✔ 1d9383d6f424 Pull complete 7.3s ✔ 8eb77e161de9 Pull complete 8.0s [+] Building 92.8s (20/20) FINISHED docker:default => [flask_crud_clientes internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 607B 0.0s => [flask_crud_clientes internal] load metadata for docker.io/library/python:3.9-slim 2.0s => [fastapi_jwt internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 392B 0.0s => [flask_crud_clientes internal] load .dockerignore 0.1s => => transferring context: 2B 0.0s => [fastapi_jwt internal] load .dockerignore 0.1s => => transferring context: 2B 0.0s => [flask_crud_clientes 1/7] FROM docker.io/library/python:3.9-slim@sha256:e9074b2ea84e00d4a73a7d0c01c52820e7b68d8901c5fa282be4f1b289d5b553 3.5s => => resolve docker.io/library/python:3.9-slim@sha256:e9074b2ea84e00d4a73a7d0c01c52820e7b68d8901c5fa282be4f1b289d5b553 0.0s => => sha256:e9074b2ea84e00d4a73a7d0c01c52820e7b68d8901c5fa282be4f1b289d5b553 1.86kB / 1.86kB 0.0s => => sha256:6a8fad40d6171de2c3cdaf6d525a004baa7781483870c3542d22fc5395cbba58 1.37kB / 1.37kB 0.0s => => sha256:462828d2b59eaff706c4558426034095e1f1100fc912fc900d432f2278552bff 7.52kB / 7.52kB 0.0s => => sha256:87c0edd565e2bf22e176bf6256f1bcc4c0dcab14ee18455a03088121ccc0c0c1 3.51MB / 3.51MB 0.6s => => sha256:9b72c177d6b8ad8d7c46581f8f20ce656696cd7502f246716f5c2ed97e42b197 11.89MB / 11.89MB 1.7s => => sha256:74338068cff92975752f0b084bf22cc5ab77b6599026084a39800d3e5a06ac64 242B / 242B 0.7s => => extracting sha256:87c0edd565e2bf22e176bf6256f1bcc4c0dcab14ee18455a03088121ccc0c0c1 0.3s => => sha256:fa96209a71e92eee3be20f9a984610d9dcba54af617aea7297d8ee1ef044b34e 3.13MB / 3.13MB 1.7s => => extracting sha256:9b72c177d6b8ad8d7c46581f8f20ce656696cd7502f246716f5c2ed97e42b197 0.9s => => extracting sha256:74338068cff92975752f0b084bf22cc5ab77b6599026084a39800d3e5a06ac64 0.0s => => extracting sha256:fa96209a71e92eee3be20f9a984610d9dcba54af617aea7297d8ee1ef044b34e 0.5s => [flask_crud_clientes internal] load build context 0.1s => => transferring context: 22.99kB 0.0s => [fastapi_jwt internal] load build context 0.1s => => transferring context: 2.47kB 0.0s => [flask_crud_clientes 2/7] WORKDIR /app 1.3s => [flask_crud_clientes 3/7] RUN apt-get update && apt-get install -y build-essential libpq-dev gcc netcat-openbsd postgresql-c 54.8s => [fastapi_jwt 3/6] RUN apt-get update && apt-get install -y build-essential libpq-dev gcc && rm -rf /var/lib/apt/lists/ 50.4s => [fastapi_jwt 4/6] COPY requirements.txt requirements.txt 0.1s => [fastapi_jwt 5/6] RUN pip install -r requirements.txt 22.9s => [flask_crud_clientes 4/7] COPY requirements.txt requirements.txt 0.1s => [flask_crud_clientes 5/7] RUN pip install -r requirements.txt 27.8s => [fastapi_jwt 6/6] COPY . /app/src 0.1s => [fastapi_jwt] exporting to image 2.6s => => exporting layers 2.6s => => writing image sha256:9dc1460797ebfeb0bf54368a249f995bcd8545e3d645d3dac14afb654111957b 0.0s => => naming to docker.io/library/ligo-clientes-fastapi_jwt 0.0s => [flask_crud_clientes 6/7] COPY . /app 0.1s => [flask_crud_clientes 7/7] RUN chmod +x entrypoint.sh 0.4s => [flask_crud_clientes] exporting to image 2.7s => => exporting layers 2.7s => => writing image sha256:f1e188bfb4e734f70da1b92bf1433a31ba612db78772db8adcbe7e9642eb7127 0.0s => => naming to docker.io/library/ligo-clientes-flask_crud_clientes 0.0s [+] Running 5/3 ✔ Network ligo-clientes_clientes_net Created 0.2s ✔ Volume "ligo-clientes_postgres_data" Created 0.0s ✔ Container postgres_db Created 0.1s ✔ Container flask_crud_clientes Created 0.1s ✔ Container fastapi_jwt Created 0.1s Attaching to fastapi_jwt, flask_crud_clientes, postgres_db postgres_db | The files belonging to this database system will be owned by user "postgres". postgres_db | This user must also own the server process. postgres_db | postgres_db | The database cluster will be initialized with locale "en_US.utf8". postgres_db | The default database encoding has accordingly been set to "UTF8". postgres_db | The default text search configuration will be set to "english". postgres_db | postgres_db | Data page checksums are disabled. postgres_db | postgres_db | fixing permissions on existing directory /var/lib/postgresql/data ... ok postgres_db | creating subdirectories ... ok postgres_db | selecting dynamic shared memory implementation ... posix postgres_db | selecting default max_connections ... 100 postgres_db | selecting default shared_buffers ... 128MB postgres_db | selecting default time zone ... Etc/UTC postgres_db | creating configuration files ... ok postgres_db | running bootstrap script ... ok flask_crud_clientes | Waiting for PostgreSQL... fastapi_jwt | INFO: Will watch for changes in these directories: ['/app'] fastapi_jwt | INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit) fastapi_jwt | INFO: Started reloader process [1] using WatchFiles postgres_db | performing post-bootstrap initialization ... ok postgres_db | initdb: warning: enabling "trust" authentication for local connections postgres_db | You can change this by editing pg_hba.conf or using the option -A, or postgres_db | --auth-local and --auth-host, the next time you run initdb. postgres_db | syncing data to disk ... ok postgres_db | postgres_db | postgres_db | Success. You can now start the database server using: postgres_db | postgres_db | pg_ctl -D /var/lib/postgresql/data -l logfile start postgres_db | postgres_db | waiting for server to start....2024-06-26 02:39:35.802 UTC [49] LOG: starting PostgreSQL 13.15 (Debian 13.15-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit postgres_db | 2024-06-26 02:39:35.806 UTC [49] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" postgres_db | 2024-06-26 02:39:35.817 UTC [50] LOG: database system was shut down at 2024-06-26 02:39:35 UTC postgres_db | 2024-06-26 02:39:35.824 UTC [49] LOG: database system is ready to accept connections postgres_db | done postgres_db | server started postgres_db | CREATE DATABASE postgres_db | postgres_db | postgres_db | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/ postgres_db | postgres_db | waiting for server to shut down...2024-06-26 02:39:36.134 UTC [49] LOG: received fast shutdown request postgres_db | .2024-06-26 02:39:36.137 UTC [49] LOG: aborting any active transactions postgres_db | 2024-06-26 02:39:36.139 UTC [49] LOG: background worker "logical replication launcher" (PID 56) exited with exit code 1 postgres_db | 2024-06-26 02:39:36.140 UTC [51] LOG: shutting down postgres_db | 2024-06-26 02:39:36.168 UTC [49] LOG: database system is shut down postgres_db | done postgres_db | server stopped postgres_db | postgres_db | PostgreSQL init process complete; ready for start up. postgres_db | postgres_db | 2024-06-26 02:39:36.274 UTC [1] LOG: starting PostgreSQL 13.15 (Debian 13.15-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit postgres_db | 2024-06-26 02:39:36.274 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 postgres_db | 2024-06-26 02:39:36.274 UTC [1] LOG: listening on IPv6 address "::", port 5432 postgres_db | 2024-06-26 02:39:36.291 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" postgres_db | 2024-06-26 02:39:36.301 UTC [64] LOG: database system was shut down at 2024-06-26 02:39:36 UTC postgres_db | 2024-06-26 02:39:36.308 UTC [1] LOG: database system is ready to accept connections fastapi_jwt | INFO: Started server process [8] fastapi_jwt | INFO: Waiting for application startup. fastapi_jwt | INFO: Application startup complete. flask_crud_clientes | PostgreSQL started flask_crud_clientes | Running database migrations... flask_crud_clientes | INFO [alembic.runtime.migration] Context impl PostgresqlImpl. flask_crud_clientes | INFO [alembic.runtime.migration] Will assume transactional DDL. flask_crud_clientes | INFO [alembic.runtime.migration] Running upgrade -> 02a9e872938f, Clientes flask_crud_clientes | Starting Flask application... flask_crud_clientes | Serving Flask app 'src:app' flask_crud_clientes | Debug mode: off flask_crud_clientes | INFO:werkzeug:WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. flask_crud_clientes | Running on all addresses (0.0.0.0) flask_crud_clientes | Running on http://127.0.0.1:5000 flask_crud_clientes | Running on http://172.18.0.4:5000 flask_crud_clientes | INFO:werkzeug:Press CTRL+C to quit flask_crud_clientes | INFO:werkzeug: Restarting with stat

Além disso, log dos containers após build: docker logs fastapi_jwt INFO: Will watch for changes in these directories: ['/app'] INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit) INFO: Started reloader process [1] using WatchFiles INFO: Started server process [8] INFO: Waiting for application startup. INFO: Application startup complete.

docker logs flask_crud_clientes Waiting for PostgreSQL... PostgreSQL started Running database migrations... INFO [alembic.runtime.migration] Context impl PostgresqlImpl. INFO [alembic.runtime.migration] Will assume transactional DDL. INFO [alembic.runtime.migration] Running upgrade -> 02a9e872938f, Clientes Starting Flask application...

walysonmaxwel commented 1 month ago

Com as versões indicadas acima, o comportamento das aplicações está funcional em meu ambiente. É possível atualizar o docker/compose e testar novamente?

jwt

mensageirodobem commented 1 month ago

O comportamento inesperado se deveu devido ao formato do fim de linha, especificamente do arquivo entrypoint.sh. Realmente no Windows, o padrão é converter o final de linha dos arquivos para CRLF. Alterei a configuração global do Git para manter a formatação original, que nesse caso específico é LF:

git config --global core.autocrlf false

Referência: Stackoverflow.

Realizado clone do repositório novamente. A aplicação foi executada corretamente.

Obrigado.