I have a Django application for the backend and a Vue application for the frontend. The app works 100% on my local machine. I am trying to dockerize the application so I can deploy it on a VPS just for someone to look at.
The front end starts up when I run docker compose up but the back end gives me the same error every time:
python3: can't open file '/app/manage.py': [Errno 2] No such file or directory
My directory structure is as follows:
back (directory)
... (django apps directories)
-- manage.py
-- Dockerfile
-- requirements.txt
front (directory)
... (vue directories)
-- Dockerfile
-- package.json
-- vite.config.js
-- index.html
Here is my Dockerfile for the backend:
FROM python:3.10
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . back
EXPOSE 8000
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
Here is my Dockerfile for the front end:
FROM node:20-alpine3.17
WORKDIR /app
COPY package.json /app/
RUN npm install
COPY . front/
EXPOSE 8080
CMD ["npm", "run", "dev:docker"]
and here is my docker-compose.yml file:
version: "1.1"
services:
db:
image: postgres:15-alpine
volumes:
- ./db:/var/lib/postgresql/data
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=postgres
back:
build: ./back
ports:
- "8000:8000"
volumes:
- ./:/back
env_file: ./back/.env
command: python3 manage.py runserver 0.0.0.0:8000
depends_on:
- db
restart: on-failure
front:
build: ./front
ports:
- "8080:8080"
volumes:
- ../front/src:/front/src
environment:
- CHOKIDAR_USEPOLLING=true
command: npm run dev
depends_on:
- back
So I have two questions please:
- Why am I getting the cannot find file error?
- When I deploy the working Docker image on the VPS how do I make it available on port 80 so if I point my domain to the VPS that I will see the complete site?
Thanks for any help.