1

The full error: enter image description here

The Dockerfile:

FROM python:3.9-alpine3.13
LABEL maintainer="arithmeticatuition.com"

ENV PYTHONUNBUFFERED 1

COPY ./requirements.txt /requirements.txt
COPY ./app /app
COPY ./scripts /scripts

WORKDIR /app
EXPOSE 8000

RUN python -m venv /py && \
    /py/bin/pip install --upgrade pip && \
    apk add --update --no-cache postgresql-client && \
    apk add --update --no-cache --virtual .tmp-deps \
        build-base postgresql-dev musl-dev linux-headers && \
    /py/bin/pip install -r /requirements.txt && \
    apk del .tmp-deps && \
    adduser --disabled-password --no-create-home app && \
    mkdir -p /vol/web/static && \
    mkdir -p /vol/web/static && \
    chown -R app:app /vol && \
    chmod -R 755 /vol  && \
    chmod -R +x /scripts

ENV PATH="/scripts:/py/bin:$PATH"

USER app

CMD ["run.sh"]

The docker-compose-deploy file:

version: '3.9'

services:
  app:
    build:
      context: .
    restart: always
    volumes:
      - static-data:/vol/web
    environment:
      - DB_HOST=db
      - DB_NAME=${DB_NAME}
      - DB_USER=${DB_USER}
      - DB_PASS=${DB_PASS}
      - SECRET_KEY=${SECRET_KEY}
      - ALLOWED_HOSTS=${ALLOWED_HOSTS}
    depends_on:
      - db

  db:
    image: postgres:13-alpine
    restart: always
    volumes:
      - postgres-data:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=${DB_NAME}
      - POSTGRES_USER=${DB_USER}
      - POSTGRES_PASSWORD=${DB_PASS}

  proxy:
    build:
      context: ./proxy
    restart: always
    depends_on:
      - app
    ports:
      - 80:8000
    volumes:
      - static-data:/vol/static

volumes:
  postgres-data:
  static-data:

I've tried everything from similar stack exchange requests but none seem to be working... I've rewatched lots of tutorials and I don't seem to be getting anywhere, who would've known that building a website in django was so much easier than deploying it to a server...

Max Smith
  • 33
  • 5
  • Please read: [Why not upload images of code/errors when asking a question?](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question) – Turing85 Oct 30 '22 at 22:12
  • Why would `/app/vol` be writable in the container, in your opinion? (Note that that's the path your app is touching, not `/vol` as you have in your dockerfile.) – AKX Oct 30 '22 at 22:14
  • As @AKX mentioned, your app code access `vol` using relative path, not absolute path, and you dockerfile specify workdir to `app`, thus your app code access `vol` at absolute path: `/app/vol`, but there is no such folder in container. – yong Oct 31 '22 at 02:15
  • @AKX thank you for your comment, i'm too new to docker to understand what this means, I've spent last few weeks busy with my course and on the side doing this but still can't work out what the fix will be regarding your comment, do I need to add a touch /app/vol ? – Max Smith Nov 11 '22 at 12:16
  • No. There's just simply a bug somewhere in your app where it tries to write to `/app/vol`, not `/vol`. – AKX Nov 11 '22 at 13:22
  • @AKX the bug is in my django code I wrote rather than the docker / proxy files? – Max Smith Nov 11 '22 at 13:31
  • Yes, since no configuration you've shown us is referring to `/app/vol`, yet the traceback is. – AKX Nov 11 '22 at 13:59

0 Answers0