I'm using docker-compose on Windows 10 19044.1766 to run containers. backend container keeps restarting with error:
standard_init_linux.go:228: exec user process caused: exec format error
dockerfile:
FROM python:3.8-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --upgrade pip
RUN pip install -r requirements.txt --no-cache-dir
COPY . /app
CMD ["gunicorn", "foodgram.wsgi:application", "--bind,", "0:8000"]
I have tried:
FROM python:3.9-slim
FROM python:3.8-slim
CMD ["gunicorn", "foodgram.wsgi:application", "--bind", "0:8000"]
CMD gunicorn foodgram.wsgi:application --bind 0:8000
CMD ["gunicorn", "foodgram.wsgi:application", "--bind"
"0.0.0.0:8000"]
Same error
docker-compose.yml
version: '3.3'
volumes:
postgres_data:
static:
media:
static_value:
media_value:
frontend_data:
services:
db:
image: postgres:12.4
volumes:
- postgres_data:/var/lib/postgresql/data/
env_file:
- ../backend/.env
backend:
image: mastermind777nest/foodgram:latest
restart: always
volumes:
- static_value:/app/static/
- media_value:/app/media/
depends_on:
- db
env_file:
- ../backend/.env
frontend:
build:
context: ../frontend
dockerfile: Dockerfile
volumes:
- ../frontend/:/app/result_build/
nginx:
image: nginx:1.19.3
ports:
- "10080:80"
- "10443:443"
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
- ../frontend/build:/usr/share/nginx/html/
- ../docs/:/usr/share/nginx/html/api/docs/
- static:/app/static/
- media:/app/media/
- static_value:/var/html/static/
- media_value:/var/html/media/
restart: always
depends_on:
- backend
- frontend
Structure
same error on remote server ubuntu Intel Ice Lake sudo docker container ls:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f3f02eaf2a41 nginx:1.19.3 "/docker-entrypoint.…" 7 minutes ago Up 7 minutes 0.0.0.0:10080->80/tcp, :::10080->80/tcp, 0.0.0.0:10443->443/tcp, :::10443->443/tcp nesterenok_nginx_1
7c03bf654bd0 mastermind777nest/foodgram:latest "gunicorn foodgram.w…" 7 minutes ago Restarting (3) 44 seconds ago nesterenok_backend_1
7b7b5aeaef71 postgres:12.4 "docker-entrypoint.s…" 25 hours ago Up 7 minutes 5432/tcp nesterenok_db_1
workflow to deploy:
name: Foodgram
on: [push]
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pep8-naming flake8-broken-line flake8-return flake8-isort
pip install -r backend/requirements.txt
- name: Test with flake8
run: python -m flake8
build_and_push_to_docker_hub:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
needs: tests
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Docker
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push to Docker Hub
uses: docker/build-push-action@v2
with:
push: true
context: ./backend/
tags: ${{ secrets.DOCKER_USERNAME }}/foodgram:latest
deploy:
runs-on: ubuntu-latest
needs: build_and_push_to_docker_hub
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
steps:
- name: executing remote ssh commands to deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USER }}
key: ${{ secrets.SSH_KEY }}
stack_file_name: docker-compose.yaml
script: |
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/foodgram:latest
sudo docker-compose stop
sudo docker-compose rm backend
sudo docker-compose up -d
send_message:
runs-on: ubuntu-latest
needs: deploy
steps:
- name: send message
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: ${{ github.workflow }} успешно выполнен!
requirements.txt
asgiref==3.5.2
atomicwrites==1.4.0
attrs==21.4.0
colorama==0.4.5
Django==4.0.5
django-filter==22.1
djangorestframework==3.13.1
flake8==4.0.1
gunicorn==20.1.0
iniconfig==1.1.1
isort==5.10.1
mccabe==0.6.1
packaging==21.3
pluggy==1.0.0
py==1.11.0
pycodestyle==2.8.0
pyflakes==2.4.0
pyparsing==3.0.9
pytest==7.1.2
pytz==2022.1
sqlparse==0.4.2
tomli==2.0.1
tzdata==2022.1
