[Vuejs]-Setting up docker for django, vue.js, rabbitmq

0👍

For the django part you’re missing a copy of your code for the django app which im assuming is in back. You’ll need to add ADD /back /code. You probably also wanna probably run the python alpine docker build instead of the ubuntu as it will significantly reduce build times and container size.

This is what I would do:

# change this to whatever python version your app is targeting (mine is typically 3.6)
FROM python:3.6-alpine

ADD /back /code

# whatever other dependencies you'll need i run with the psycopg2-binary build so i need these (the nice part of the python-alpine image is you don't need to install any of those python specific packages you were installing before
RUN apk add --virtual .build-deps gcc musl-dev postgresql-dev

RUN pip install -r /code/requirements.txt

# expose whatever port you need for your Django app (default is 8000, we use non-default but you can do whatever you need)
EXPOSE 8000

WORKDIR /code

#dont need /code here since WORKDIR is effectively a change directory

RUN chmod +x /run-django.sh
RUN apk add --no-cache bash postgresql-libs

CMD ["/run-django.sh"]

We have a similar run-django.sh script that we call python manage.py makemigrations and python manage.py migrate. I’m assuming yours is similar.

Long story short, you weren’t copying in the code from back to code.

Also in your docker-compose you dont have build context like you do for the vue service.

As for your rabbitmq container failure, you need to stop the /etc service associated with rabbit on your computer. I get this error if i’m trying to expose a postgresql container or a redis container and have to /etc/init.d/postgresql stop or /etc/init.d/redis stop to stop the service running on your machine in order to allow for no collisions on that default port for that service.

Leave a comment